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