mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Raise ValueError when floor dims absent and synthesis guards cannot fire 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e62e5fbfe4
commit
8024065d04
2 changed files with 18 additions and 0 deletions
|
|
@ -2968,6 +2968,12 @@ def _sap_17_1_building_part(
|
|||
)
|
||||
]
|
||||
else:
|
||||
if not bp.sap_floor_dimensions:
|
||||
raise ValueError(
|
||||
f"building_part {bp.building_part_number!r}: sap_floor_dimensions "
|
||||
f"is empty and cannot be synthesised (is_single_part={is_single_part}, "
|
||||
f"is_flat={is_flat})"
|
||||
)
|
||||
floor_dimensions = [
|
||||
SapFloorDimension(
|
||||
room_height_m=fd.storey_height,
|
||||
|
|
|
|||
|
|
@ -817,3 +817,15 @@ class TestFullSapSchema16xNoFloorDimensions:
|
|||
|
||||
# Act / Assert
|
||||
assert fd.heat_loss_perimeter_m == pytest.approx(47.08)
|
||||
|
||||
def test_raises_when_floor_dims_absent_and_synthesis_not_possible(
|
||||
self,
|
||||
) -> None:
|
||||
# Arrange: strip sap_flat_details so is_flat=False — synthesis guard
|
||||
# cannot fire, empty floor dims must raise rather than silently produce [].
|
||||
data = load("sap_16_0_full_no_floor_dims.json")
|
||||
data.pop("sap_flat_details", None)
|
||||
|
||||
# Act / Assert
|
||||
with pytest.raises(ValueError, match="sap_floor_dimensions"):
|
||||
EpcPropertyDataMapper.from_api_response(data)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue