Derive hot-water bath and mixer counts from room counts for 18.0 certs 🟥

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-11 12:02:16 +00:00
parent e0d3d3fd2a
commit 6df307b49c

View file

@ -1671,3 +1671,37 @@ class TestRdSap18_0ReducedFieldSynthesis:
assert result.sap_ventilation.sheltered_sides == _api_sheltered_sides(
cert["built_form"]
)
def test_hot_water_derives_bath_and_mixer_counts_from_room_counts(self) -> None:
# Arrange — ADR-0028: 18.0's instantaneous_wwhrs carries bath/shower ROOM
# counts (a false-friend for the WWHR device index), populated 1000/1000.
# Derive number_baths and mixer_shower_count so HW demand isn't pinned to
# the calculator's modal 1-bath default.
corpus = _load_18_0_corpus()
if not corpus:
pytest.skip("no RdSAP-Schema-18.0 corpus harvested")
cert = next(
(
c
for c in corpus
if not c.get("sap_windows")
and c.get("sap_heating", {}).get("instantaneous_wwhrs")
),
None,
)
if cert is None:
pytest.skip("no corpus cert with instantaneous_wwhrs")
iw = cert["sap_heating"]["instantaneous_wwhrs"]
expected_baths = iw["rooms_with_bath_and_or_shower"] + iw[
"rooms_with_bath_and_mixer_shower"
]
expected_mixers = iw["rooms_with_mixer_shower_no_bath"] + iw[
"rooms_with_bath_and_mixer_shower"
]
# Act
result = EpcPropertyDataMapper.from_api_response(cert)
# Assert
assert result.sap_heating.number_baths == expected_baths
assert result.sap_heating.mixer_shower_count == expected_mixers