SPlit up
Some checks failed
CI / Check (push) Failing after 1m58s
Build and publish Docker image / build-and-push (push) Failing after 1m5s

This commit is contained in:
Andras Schmelczer 2026-06-12 21:51:37 +01:00
parent cf39ad754e
commit f59d01227b
91 changed files with 10370 additions and 7562 deletions

View file

@ -6,13 +6,13 @@ from pipeline.download.rental_prices import _latest_rents_long
def test_latest_rents_long_adds_iod_alias_codes_for_south_yorkshire():
raw = pl.DataFrame(
{
"column_1": ["title", "header", "2026-02-01 00:00:00"],
"column_2": ["", "", "E08000038"],
"column_3": ["", "", "Barnsley"],
"column_12": ["", "", "486"],
"column_16": ["", "", "595"],
"column_20": ["", "", "705"],
"column_24": ["", "", "900"],
"column_1": ["title", "Time period", "2026-02-01 00:00:00"],
"column_2": ["", "Area code", "E08000038"],
"column_3": ["", "Area name", "Barnsley"],
"column_12": ["", "One bed", "486"],
"column_16": ["", "Two bed", "595"],
"column_20": ["", "Three bed", "705"],
"column_24": ["", "Four or more bed", "900"],
}
)
@ -22,3 +22,30 @@ def test_latest_rents_long_adds_iod_alias_codes_for_south_yorkshire():
{"area_code": "E08000016", "mean_monthly_rent": 486.0},
{"area_code": "E08000038", "mean_monthly_rent": 486.0},
]
def test_latest_rents_long_locates_header_in_variable_preamble():
"""The live workbook has THREE preamble rows (title, contents note,
header); a fixed two-row slice left the header in the data and only the
area-code filter happened to drop it."""
raw = pl.DataFrame(
{
"column_1": [
"title",
"This worksheet contains one table.",
"Time period",
"2026-02-01 00:00:00",
],
"column_2": ["", "", "Area code", "E08000038"],
"column_3": ["", "", "Area name", "Barnsley"],
"column_12": ["", "", "One bed", "486"],
"column_16": ["", "", "Two bed", "595"],
"column_20": ["", "", "Three bed", "705"],
"column_24": ["", "", "Four or more bed", "900"],
}
)
result = _latest_rents_long(raw)
assert result.filter(pl.col("area_code") == "E08000038").height == 5
assert result["mean_monthly_rent"].null_count() == 0