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:
Daniel Roth 2026-06-25 15:03:03 +00:00
parent e62e5fbfe4
commit 8024065d04
2 changed files with 18 additions and 0 deletions

View file

@ -2968,6 +2968,12 @@ def _sap_17_1_building_part(
) )
] ]
else: 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 = [ floor_dimensions = [
SapFloorDimension( SapFloorDimension(
room_height_m=fd.storey_height, room_height_m=fd.storey_height,

View file

@ -817,3 +817,15 @@ class TestFullSapSchema16xNoFloorDimensions:
# Act / Assert # Act / Assert
assert fd.heat_loss_perimeter_m == pytest.approx(47.08) 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)