mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Coerce banded flat_location string to its floor integer 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1edf2be345
commit
862a7ccc61
1 changed files with 17 additions and 0 deletions
|
|
@ -458,6 +458,23 @@ class TestFromRdSapSchema21_0_1:
|
|||
|
||||
assert result.led_fixed_lighting_bulbs_count == 0
|
||||
|
||||
def test_banded_flat_location_string_coerced_to_band_floor_int(self) -> None:
|
||||
# The gov API lodges flat_location (the flat's floor number) as a plain
|
||||
# int on most certs, but on high floors as a banded string "20+" (floor
|
||||
# 20 or above) — e.g. cert 2481-2122-4211-1172-4722 (UPRN 6027561).
|
||||
# The epc_flat_details.flat_location column is a NOT-NULL integer, so the
|
||||
# raw string crashed the modelling_e2e insert (psycopg2
|
||||
# InvalidTextRepresentation, portfolio 796 run). Coerce the band to its
|
||||
# floor (20); Elmhurst caps the floor number at 30.
|
||||
data = load("21_0_1.json")
|
||||
data["sap_flat_details"]["flat_location"] = "20+"
|
||||
schema = from_dict(RdSapSchema21_0_1, data)
|
||||
|
||||
result = EpcPropertyDataMapper.from_rdsap_schema_21_0_1(schema)
|
||||
|
||||
assert result.sap_flat_details is not None
|
||||
assert result.sap_flat_details.flat_location == 20
|
||||
|
||||
def test_uprn(self, result: EpcPropertyData) -> None:
|
||||
assert result.uprn == 12457
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue