Map window custom_displayable_fields to WindowVentilation 🟥

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-06-05 12:47:50 +00:00
parent 5a582bbff0
commit 10bbf0bb60
2 changed files with 40 additions and 0 deletions

View file

@ -1,4 +1,19 @@
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class WindowVentilation:
opening_type: Optional[str] = None
num_openings: Optional[int] = None
pct_openable: Optional[int] = None
trickle_vent_area_mm2: Optional[int] = None
num_trickle_vents: Optional[int] = None
@dataclass
class DoorVentilation:
undercut_mm: Optional[float] = None
@dataclass
@ -7,11 +22,13 @@ class Window:
height_m: float
area_m2: float
opening_type: str
ventilation: Optional[WindowVentilation] = None
@dataclass
class Door:
width_mm: float # TODO: should this be m or mm?
ventilation: Optional[DoorVentilation] = None
@dataclass

View file

@ -225,3 +225,26 @@ def plan4() -> Plan:
def test_plan4_address_uses_street_number_when_street_absent(plan4: Plan):
assert plan4.address == "2, Bromley, GB"
# --- New fixture: new-format API response with custom_displayable_fields ---
NEW_FIXTURE_DIR = Path(__file__).parents[4] / "tests" / "magic_plan"
@pytest.fixture(scope="module")
def plan_new() -> Plan:
payload = json.loads(
(NEW_FIXTURE_DIR / "magicplan_api_plan_response.json").read_text()
)
return map_plan(MagicPlanPlan.model_validate(payload["data"]))
def test_kitchen_window_has_ventilation(plan_new: Plan) -> None:
# Arrange — Kitchen is floor 0 room 0; its only window is a windowcasement
# with custom_displayable_fields populated in the new fixture.
window = plan_new.floors[0].rooms[0].windows[0]
# Assert
assert window.ventilation is not None
assert window.ventilation.trickle_vent_area_mm2 == 1700