added back exposed floor recommendations

This commit is contained in:
Khalim Conn-Kowlessar 2024-09-30 15:55:25 +01:00
parent 80579989fc
commit 1e5661bf3a

View file

@ -5,6 +5,7 @@ from unittest.mock import Mock
from recommendations.FloorRecommendations import FloorRecommendations from recommendations.FloorRecommendations import FloorRecommendations
from recommendations.tests.test_data.materials import materials from recommendations.tests.test_data.materials import materials
from backend.Property import Property from backend.Property import Property
from etl.epc.Record import EPCRecord
# import inspect # import inspect
@ -152,123 +153,131 @@ class TestFloorRecommendations:
assert recommender.estimated_u_value is None assert recommender.estimated_u_value is None
assert not recommender.recommendations assert not recommender.recommendations
# def test_exposed_floor_no_insulation(self): def test_exposed_floor_no_insulation(self):
# input_property = Property(id=1, postcode="F4k3 2", address1="223 fake street", epc_client=Mock()) epc_record = EPCRecord()
# input_property.floor = { epc_record.prepared_epc = {"county": "Greater London", "floor-level": 0, "property-type": "House"}
# 'original_description': 'To unheated space, no insulation (assumed)', epc_record.full_sap_epc = {}
# 'clean_description': 'To unheated space, no insulation', 'thermal_transmittance': None,
# 'thermal_transmittance_unit': None, 'is_assumed': True, 'is_to_unheated_space': True, input_property = Property(id=1, postcode="F4k3 2", address="223 fake street", epc_record=epc_record)
# 'is_to_external_air': False, 'is_suspended': False, 'is_solid': False, 'another_property_below': False, input_property.floor = {
# 'insulation_thickness': 'none' 'original_description': 'To unheated space, no insulation (assumed)',
# } 'clean_description': 'To unheated space, no insulation', 'thermal_transmittance': None,
# input_property.age_band = "L" 'thermal_transmittance_unit': None, 'is_assumed': True, 'is_to_unheated_space': True,
# input_property.set_floor_type() 'is_to_external_air': False, 'is_suspended': False, 'is_solid': False, 'another_property_below': False,
# input_property.data = {"floor-level": 0, "property-type": "House"} 'insulation_thickness': 'none'
# input_property.floor_area = 100 }
# input_property.number_of_floors = 1 input_property.age_band = "L"
# input_property.set_floor_type()
# recommender = FloorRecommendations( input_property.floor_area = 100
# property_instance=input_property, input_property.number_of_floors = 1
# materials=materials
# ) recommender = FloorRecommendations(
# property_instance=input_property,
# assert not recommender.recommendations materials=materials
# )
# recommender.recommend()
# assert not recommender.recommendations
# # Because of age band L, this should have a u-value of 0.22 to begin with and no recommendation
# assert not len(recommender.recommendations) recommender.recommend()
# assert recommender.estimated_u_value == 0.22
# # Because of age band L, this should have a u-value of 0.22 to begin with and no recommendation
# # Now with an older age band assert not len(recommender.recommendations)
# assert recommender.estimated_u_value == 0.22
# input_property2 = Property(id=1, postcode="F4k3 2", address1="223 fake street", epc_client=Mock())
# input_property2.floor = { # Now with an older age band
# 'original_description': 'To unheated space, no insulation (assumed)', epc_record2 = EPCRecord()
# 'clean_description': 'To unheated space, no insulation', 'thermal_transmittance': None, epc_record2.prepared_epc = {"county": "Greater London", "floor-level": 0, "property-type": "House"}
# 'thermal_transmittance_unit': None, 'is_assumed': True, 'is_to_unheated_space': True, epc_record2.full_sap_epc = {}
# 'is_to_external_air': False, 'is_suspended': False, 'is_solid': False, 'another_property_below': False,
# 'insulation_thickness': 'none' input_property2 = Property(id=1, postcode="F4k3 2", address="223 fake street", epc_record=epc_record2)
# } input_property2.floor = {
# input_property2.age_band = "D" 'original_description': 'To unheated space, no insulation (assumed)',
# input_property2.set_floor_type() 'clean_description': 'To unheated space, no insulation', 'thermal_transmittance': None,
# input_property2.data = {"floor-level": 0, "property-type": "House"} 'thermal_transmittance_unit': None, 'is_assumed': True, 'is_to_unheated_space': True,
# input_property2.floor_area = 100 'is_to_external_air': False, 'is_suspended': False, 'is_solid': False, 'another_property_below': False,
# input_property2.number_of_floors = 1 'insulation_thickness': 'none'
# }
# recommender2 = FloorRecommendations( input_property2.age_band = "D"
# property_instance=input_property2, input_property2.set_floor_type()
# materials=materials input_property2.insulation_floor_area = 100
# ) input_property2.number_of_floors = 1
#
# assert not recommender2.recommendations recommender2 = FloorRecommendations(
# property_instance=input_property2,
# recommender2.recommend() materials=materials
# )
# assert len(recommender2.recommendations) == 1
# assert not recommender2.recommendations
# assert recommender2.recommendations[0]["new_u_value"] == 0.23
# assert recommender2.recommendations[0]["starting_u_value"] == 1.2 recommender2.recommend()
# assert recommender2.recommendations[0]["cost"] == 1500
# assert len(recommender2.recommendations) == 1
# def test_exposed_floor_below_average_insulated(self):
# input_property3 = Property(id=1, postcode="F4k3 2", address1="223 fake street", epc_client=Mock()) assert recommender2.recommendations[0]["new_u_value"] == 0.24
# input_property3.floor = { assert recommender2.recommendations[0]["starting_u_value"] == 1.2
# 'original_description': 'To unheated space, below average insulation (assumed)', assert recommender2.recommendations[0]["total"] == 9375
# 'clean_description': 'To unheated space, below average insulation', 'thermal_transmittance': None,
# 'thermal_transmittance_unit': None, 'is_assumed': True, 'is_to_unheated_space': True, def test_exposed_floor_below_average_insulated(self):
# 'is_to_external_air': False, 'is_suspended': False, 'is_solid': False, 'another_property_below': False, epc_record3 = EPCRecord()
# 'insulation_thickness': 'below average' epc_record3.prepared_epc = {"county": "Greater London", "floor-level": 0, "property-type": "House"}
# } epc_record3.full_sap_epc = {}
# input_property3.age_band = "C" input_property3 = Property(id=1, postcode="F4k3 2", address="223 fake street", epc_record=epc_record3)
# input_property3.set_floor_type() input_property3.floor = {
# input_property3.data = {"floor-level": 0, "property-type": "House"} 'original_description': 'To unheated space, below average insulation (assumed)',
# input_property3.floor_area = 100 'clean_description': 'To unheated space, below average insulation', 'thermal_transmittance': None,
# input_property3.number_of_floors = 1 'thermal_transmittance_unit': None, 'is_assumed': True, 'is_to_unheated_space': True,
# 'is_to_external_air': False, 'is_suspended': False, 'is_solid': False, 'another_property_below': False,
# recommender3 = FloorRecommendations( 'insulation_thickness': 'below average'
# property_instance=input_property3, }
# materials=materials input_property3.age_band = "C"
# ) input_property3.set_floor_type()
# input_property3.insulation_floor_area = 100
# assert not recommender3.recommendations input_property3.number_of_floors = 1
#
# recommender3.recommend() recommender3 = FloorRecommendations(
# property_instance=input_property3,
# assert recommender3.estimated_u_value == 0.5 materials=materials
# )
# assert len(recommender3.recommendations) == 1
# assert not recommender3.recommendations
# assert recommender3.recommendations[0]["new_u_value"] == 0.22
# assert recommender3.recommendations[0]["starting_u_value"] == 0.5 recommender3.recommend()
# assert recommender3.recommendations[0]["cost"] == 1100
# assert recommender3.recommendations[0]["parts"][0]["depths"] == [100] assert recommender3.estimated_u_value == 0.5
#
# # With average insulation, no recommendations assert len(recommender3.recommendations) == 1
#
# input_property4 = Property(id=1, postcode="F4k3 2", address1="223 fake street", epc_client=Mock()) assert recommender3.recommendations[0]["new_u_value"] == 0.24
# input_property4.floor = { assert recommender3.recommendations[0]["starting_u_value"] == 0.5
# 'original_description': 'To unheated space, insulated (assumed)', assert recommender3.recommendations[0]["total"] == 7500
# 'clean_description': 'To unheated space, insulated', 'thermal_transmittance': None, assert recommender3.recommendations[0]["parts"][0]["depth"] == 50
# 'thermal_transmittance_unit': None, 'is_assumed': True, 'is_to_unheated_space': True,
# 'is_to_external_air': False, 'is_suspended': False, 'is_solid': False, 'another_property_below': False, # With average insulation, no recommendations
# 'insulation_thickness': 'average' epc_record4 = EPCRecord()
# } epc_record4.prepared_epc = {"county": "Greater London", "floor-level": 0, "property-type": "House"}
# input_property4.age_band = "C" epc_record4.full_sap_epc = {}
# input_property4.set_floor_type() input_property4 = Property(id=1, postcode="F4k3 2", address="223 fake street", epc_record=epc_record4)
# input_property4.data = {"floor-level": 0, "property-type": "House"} input_property4.floor = {
# input_property4.floor_area = 100 'original_description': 'To unheated space, insulated (assumed)',
# input_property4.number_of_floors = 1 'clean_description': 'To unheated space, insulated', 'thermal_transmittance': None,
# 'thermal_transmittance_unit': None, 'is_assumed': True, 'is_to_unheated_space': True,
# recommender4 = FloorRecommendations( 'is_to_external_air': False, 'is_suspended': False, 'is_solid': False, 'another_property_below': False,
# property_instance=input_property4, 'insulation_thickness': 'average'
# materials=materials }
# ) input_property4.age_band = "C"
# input_property4.set_floor_type()
# assert not recommender4.recommendations input_property4.insulation_floor_area = 100
# input_property4.number_of_floors = 1
# recommender4.recommend()
# recommender4 = FloorRecommendations(
# assert recommender4.estimated_u_value is None property_instance=input_property4,
# materials=materials
# assert len(recommender4.recommendations) == 0 )
assert not recommender4.recommendations
recommender4.recommend()
assert recommender4.estimated_u_value is None
assert len(recommender4.recommendations) == 0