Synthesise lighting bulb counts from outlet 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 11:59:33 +00:00
parent fb14f03873
commit 70af9dee65

View file

@ -1605,3 +1605,35 @@ class TestRdSap18_0ReducedFieldSynthesis:
# Assert — every synthesised window has an int glazing_type, not "ND".
assert result.sap_windows
assert all(isinstance(w.glazing_type, int) for w in result.sap_windows)
def test_lighting_counts_incandescent_remainder_and_low_energy_as_lel(
self,
) -> None:
# Arrange — ADR-0028: 18.0 gives total + low-energy OUTLET counts, not an
# LED/CFL/incandescent split (matches 20.0.0). The non-low-energy
# remainder is incandescent (else lighting energy is understated); the
# low-energy outlets feed the calculator's LEL path. A cert with some
# incandescent (non-low-energy) outlets.
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 (c.get("fixed_lighting_outlets_count") or 0)
> (c.get("low_energy_fixed_lighting_outlets_count") or 0)
),
None,
)
if cert is None:
pytest.skip("no corpus cert with incandescent lighting")
total = cert["fixed_lighting_outlets_count"]
low = cert["low_energy_fixed_lighting_outlets_count"]
# Act
result = EpcPropertyDataMapper.from_api_response(cert)
# Assert
assert result.incandescent_fixed_lighting_bulbs_count == total - low
assert result.low_energy_fixed_lighting_bulbs_count == low