From 9e6ff3e48d0c28dc5ae5145f9b043b6ddb825d05 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 11 Feb 2026 13:57:56 +0000 Subject: [PATCH] map empty description to null outputs for Roof Attributes and updated tests. Removed redundant repeat test --- etl/epc_clean/epc_attributes/RoofAttributes.py | 6 ++++++ etl/epc_clean/tests/test_roof_attributes.py | 13 ++----------- recommendations/RoofRecommendations.py | 6 +++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/etl/epc_clean/epc_attributes/RoofAttributes.py b/etl/epc_clean/epc_attributes/RoofAttributes.py index 98998e5a..7e2aed2c 100644 --- a/etl/epc_clean/epc_attributes/RoofAttributes.py +++ b/etl/epc_clean/epc_attributes/RoofAttributes.py @@ -74,6 +74,8 @@ class RoofAttributes(Definitions): "insulation_thickness", ] + NODATA_NULLS = ["insulation_thickness", "thermal_transmittance", "thermal_transmittance_unit"] + def __init__(self, description: str): """ :param description: Description of the roof. @@ -153,6 +155,10 @@ class RoofAttributes(Definitions): if self.nodata: for key in self.DEFAULT_KEYS: result[key] = False + # Insulation thickness, thermal transmittance and thermal transmittance unit are set to None for nodata + # cases + for k in self.NODATA_NULLS: + result[k] = None return result description = self.description diff --git a/etl/epc_clean/tests/test_roof_attributes.py b/etl/epc_clean/tests/test_roof_attributes.py index 33c6a829..d0d277c7 100644 --- a/etl/epc_clean/tests/test_roof_attributes.py +++ b/etl/epc_clean/tests/test_roof_attributes.py @@ -26,9 +26,9 @@ class TestRoofAttributes: def test_empty_str(self): # Test initialization with an empty description assert RoofAttributes('').process() == { - 'thermal_transmittance': False, 'thermal_transmittance_unit': False, 'is_pitched': False, + 'thermal_transmittance': None, 'thermal_transmittance_unit': None, 'is_pitched': False, 'is_roof_room': False, 'is_loft': False, 'is_flat': False, 'is_thatched': False, 'is_at_rafters': False, - 'is_assumed': False, 'has_dwelling_above': False, 'is_valid': False, 'insulation_thickness': False + 'is_assumed': False, 'has_dwelling_above': False, 'is_valid': False, 'insulation_thickness': None } assert set(list(RoofAttributes('').process().values())) == {False} @@ -92,15 +92,6 @@ class TestRoofAttributes: with pytest.raises(ValueError): RoofAttributes('nonsense string').process() - def test_clean_roof_no_description(self): - roof = RoofAttributes('').process() - assert roof == { - 'thermal_transmittance': False, 'thermal_transmittance_unit': False, 'is_pitched': False, - 'is_roof_room': False, 'is_loft': False, 'is_flat': False, 'is_thatched': False, - 'is_at_rafters': False, 'is_assumed': False, 'has_dwelling_above': False, 'is_valid': False, - 'insulation_thickness': False - } - def test_clean_roof_edge_cases(self): # Insulation thickness edge case assert RoofAttributes('Pitched, 99999 mm loft insulation').process()['insulation_thickness'] == "99999" diff --git a/recommendations/RoofRecommendations.py b/recommendations/RoofRecommendations.py index f88a672b..5e118844 100644 --- a/recommendations/RoofRecommendations.py +++ b/recommendations/RoofRecommendations.py @@ -59,9 +59,9 @@ class RoofRecommendations: # Extract the insulation thickness from the roof, which is used throughout this method self.insulation_thickness = convert_thickness_to_numeric( - self.property.roof["insulation_thickness"], - self.property.roof["is_pitched"], - self.property.roof["is_flat"] + string_thickness=self.property.roof["insulation_thickness"], + is_pitched=self.property.roof["is_pitched"], + is_flat=self.property.roof["is_flat"] ) @classmethod