diff --git a/datatypes/epc/domain/mapper.py b/datatypes/epc/domain/mapper.py index 10ec411d..26704922 100644 --- a/datatypes/epc/domain/mapper.py +++ b/datatypes/epc/domain/mapper.py @@ -2172,7 +2172,7 @@ class EpcPropertyDataMapper: # to 0 like every other mapper (RdSAP "not lodged" → calc minimum 1). wet_rooms_count=schema.wet_rooms_count or 0, extensions_count=schema.extensions_count, - open_chimneys_count=schema.open_chimneys_count, + open_chimneys_count=schema.open_chimneys_count or 0, insulated_door_count=schema.insulated_door_count, draughtproofed_door_count=schema.draughtproofed_door_count, # Mechanical ventilation PCDB plumbing — feeds the §5 Table 4f @@ -2188,8 +2188,8 @@ class EpcPropertyDataMapper: ), mechanical_vent_duct_type=schema.mechanical_vent_duct_type, # Lighting - led_fixed_lighting_bulbs_count=schema.led_fixed_lighting_bulbs_count, - cfl_fixed_lighting_bulbs_count=schema.cfl_fixed_lighting_bulbs_count, + led_fixed_lighting_bulbs_count=schema.led_fixed_lighting_bulbs_count or 0, + cfl_fixed_lighting_bulbs_count=schema.cfl_fixed_lighting_bulbs_count or 0, incandescent_fixed_lighting_bulbs_count=schema.incandescent_fixed_lighting_bulbs_count, # Energy elements roofs=EpcPropertyDataMapper._map_energy_elements(schema.roofs), diff --git a/datatypes/epc/domain/tests/test_from_rdsap_schema.py b/datatypes/epc/domain/tests/test_from_rdsap_schema.py index a2463eae..440325ce 100644 --- a/datatypes/epc/domain/tests/test_from_rdsap_schema.py +++ b/datatypes/epc/domain/tests/test_from_rdsap_schema.py @@ -431,6 +431,33 @@ class TestFromRdSapSchema21_0_1: assert result.wet_rooms_count == 0 + def test_omitted_open_chimneys_count_defaults_to_zero_not_none(self) -> None: + data = load("21_0_1.json") + data.pop("open_chimneys_count", None) + schema = from_dict(RdSapSchema21_0_1, data) + + result = EpcPropertyDataMapper.from_rdsap_schema_21_0_1(schema) + + assert result.open_chimneys_count == 0 + + def test_omitted_cfl_fixed_lighting_bulbs_count_defaults_to_zero_not_none(self) -> None: + data = load("21_0_1.json") + data.pop("cfl_fixed_lighting_bulbs_count", None) + schema = from_dict(RdSapSchema21_0_1, data) + + result = EpcPropertyDataMapper.from_rdsap_schema_21_0_1(schema) + + assert result.cfl_fixed_lighting_bulbs_count == 0 + + def test_omitted_led_fixed_lighting_bulbs_count_defaults_to_zero_not_none(self) -> None: + data = load("21_0_1.json") + data.pop("led_fixed_lighting_bulbs_count", None) + schema = from_dict(RdSapSchema21_0_1, data) + + result = EpcPropertyDataMapper.from_rdsap_schema_21_0_1(schema) + + assert result.led_fixed_lighting_bulbs_count == 0 + def test_uprn(self, result: EpcPropertyData) -> None: assert result.uprn == 12457 diff --git a/tests/harness/test_report.py b/tests/harness/test_report.py index 6b8bc9a4..304f8940 100644 --- a/tests/harness/test_report.py +++ b/tests/harness/test_report.py @@ -179,7 +179,7 @@ def test_few_measure_cert_surfaces_only_its_fired_measures_triggers() -> None: } assert triggers["low_energy_lighting"].triggers == { "incandescent_fixed_lighting_bulbs_count": 0, - "cfl_fixed_lighting_bulbs_count": None, + "cfl_fixed_lighting_bulbs_count": 0, "low_energy_fixed_lighting_bulbs_count": 7, }