From eb277b4e8af66765d9283d5597e6501613f06ab1 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 17 Nov 2023 11:02:54 +0000 Subject: [PATCH] Added limited flat roof insulaton --- recommendations/RoofRecommendations.py | 1 + .../tests/test_roof_recommendations.py | 39 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/recommendations/RoofRecommendations.py b/recommendations/RoofRecommendations.py index daaa523c..283370ac 100644 --- a/recommendations/RoofRecommendations.py +++ b/recommendations/RoofRecommendations.py @@ -123,6 +123,7 @@ class RoofRecommendations: for material in materials: for depth, cost_per_unit in zip(material["depths"], material["cost"]): + # We make sure we hit a depth of 270mm. We should factor in any existing insulation if the # loft is already partially insulated if (depth + insulation_thickness) < self.MINIMUM_LOFT_ISULATION_MM: diff --git a/recommendations/tests/test_roof_recommendations.py b/recommendations/tests/test_roof_recommendations.py index 04ab5f77..a3cc9266 100644 --- a/recommendations/tests/test_roof_recommendations.py +++ b/recommendations/tests/test_roof_recommendations.py @@ -55,7 +55,7 @@ flat_roof_insulation_materials = [ 'description': 'Example flat roof insulation', 'depths': [50, 150, 220, 270, 300], 'depth_unit': 'mm', 'cost': [9, 10, 11, 12, 13], 'cost_unit': 'gbp_sq_meter', - 'r_value_per_mm': 0.022727273, 'r_value_unit': 'square_meter_kelvin_per_watt', + 'r_value_per_mm': 0.032727273, 'r_value_unit': 'square_meter_kelvin_per_watt', 'thermal_conductivity': 0.044, 'thermal_conductivity_unit': 'watt_per_meter_kelvin', 'link': None, 'is_active': True } @@ -343,11 +343,6 @@ class TestRoofRecommendations: "Insulate your room roof with 270mm of Example room roof insulation" def test_flat_no_insulation(self): - # Desriptions to handle: - # 'Flat, limited insulation (assumed)', - # - # 'Flat, insulated (assumed)' - property_instance11 = Property(id=11, address1="fake", postcode="fake", epc_client=Mock()) property_instance11.age_band = "D" property_instance11.floor_area = 150 @@ -405,3 +400,35 @@ class TestRoofRecommendations: roof_recommender12.recommend() assert not roof_recommender12.recommendations + + def test_flat_limited_insulation(self): + property_instance13 = Property(id=12, address1="fake", postcode="fake", epc_client=Mock()) + property_instance13.age_band = "D" + property_instance13.floor_area = 150 + property_instance13.roof = { + 'original_description': 'Flat, limited insulation (assumed)', + 'clean_description': 'Flat, limited insulation', + 'thermal_transmittance': None, 'thermal_transmittance_unit': None, 'is_pitched': False, + 'is_roof_room': False, + 'is_loft': False, 'is_flat': True, 'is_thatched': False, 'is_at_rafters': False, 'is_assumed': True, + 'has_dwelling_above': False, 'is_valid': True, 'insulation_thickness': 'below average' + } + + roof_recommender13 = RoofRecommendations( + property_instance=property_instance13, materials=flat_roof_insulation_materials + ) + + assert not roof_recommender13.recommendations + + roof_recommender13.recommend() + + assert len(roof_recommender13.recommendations) == 1 + + assert roof_recommender13.recommendations[0]["parts"][0]["depths"] == [220] + + assert roof_recommender13.recommendations[0]["new_u_value"] == 0.14 + + assert roof_recommender13.recommendations[0]["starting_u_value"] == 2.3 + + assert roof_recommender13.recommendations[0]["description"] == \ + "Insulate the home's flat roof with 220mm of Example flat roof insulation"