mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
test: floor-dimension heat-loss flags must round-trip 🟥
is_exposed_floor / is_above_partially_heated_space have no epc_floor_dimension column, so a True flag round-trips back to the False default and silently flips the floor's heat-loss path (persist != score). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6303343575
commit
c04692f9f5
1 changed files with 36 additions and 0 deletions
|
|
@ -86,6 +86,42 @@ def test_non_separated_conservatory_round_trips(db_engine: Engine) -> None:
|
|||
assert reloaded == original
|
||||
|
||||
|
||||
def test_floor_dimension_heat_loss_flags_round_trip(db_engine: Engine) -> None:
|
||||
# SAP 10.2 §3.3 — `is_exposed_floor` and `is_above_partially_heated_space`
|
||||
# are heat-loss flags on a `SapFloorDimension`: the calculator routes a floor
|
||||
# over outside air / over a partially-heated space through a different
|
||||
# U-value path. They had no `epc_floor_dimension` column, so a True flag
|
||||
# round-tripped back to the `False` default and silently flipped the floor's
|
||||
# heat loss (persist != score). We force both True on a clean fixture so the
|
||||
# ONLY thing that can break deep-equality is these two flags.
|
||||
from dataclasses import replace
|
||||
|
||||
# Arrange — a green fixture with a floor dimension, both flags forced True.
|
||||
original = _load_epc("RdSAP-Schema-21.0.0")
|
||||
assert original.sap_building_parts, "fixture must have a building part"
|
||||
bp0 = original.sap_building_parts[0]
|
||||
assert bp0.sap_floor_dimensions, "fixture building part must have a floor dimension"
|
||||
dim0 = replace(
|
||||
bp0.sap_floor_dimensions[0],
|
||||
is_exposed_floor=True,
|
||||
is_above_partially_heated_space=True,
|
||||
)
|
||||
bp0 = replace(bp0, sap_floor_dimensions=[dim0, *bp0.sap_floor_dimensions[1:]])
|
||||
original = replace(
|
||||
original, sap_building_parts=[bp0, *original.sap_building_parts[1:]]
|
||||
)
|
||||
|
||||
# Act
|
||||
with Session(db_engine) as session:
|
||||
epc_property_id = EpcPostgresRepository(session).save(original)
|
||||
session.commit()
|
||||
with Session(db_engine) as session:
|
||||
reloaded = EpcPostgresRepository(session).get(epc_property_id)
|
||||
|
||||
# Assert — both flags survive the round-trip, deep-equal.
|
||||
assert reloaded == original
|
||||
|
||||
|
||||
def test_building_part_wall_insulation_thickness_preserves_int(
|
||||
db_engine: Engine,
|
||||
) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue