mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Added first floor recommendation tests
This commit is contained in:
parent
3f43ef3ee9
commit
590decce61
3 changed files with 57 additions and 14 deletions
|
|
@ -12,6 +12,7 @@ class BaseUtility:
|
||||||
# When the energy certificate was first lodged on the register there was no requirement to lodge this data
|
# When the energy certificate was first lodged on the register there was no requirement to lodge this data
|
||||||
# item, i.e. a non-mandatory item.
|
# item, i.e. a non-mandatory item.
|
||||||
"NO DATA!",
|
"NO DATA!",
|
||||||
|
"NODATA!",
|
||||||
# When the energy certificate was first lodged on the register there was no requirement to lodge this data item,
|
# When the energy certificate was first lodged on the register there was no requirement to lodge this data item,
|
||||||
# i.e.a non - mandatory item.
|
# i.e.a non - mandatory item.
|
||||||
"N/A",
|
"N/A",
|
||||||
|
|
|
||||||
|
|
@ -83,11 +83,13 @@ class FloorRecommendations(BaseUtility):
|
||||||
|
|
||||||
PART_L_YEAR_CUTOFF = 2002
|
PART_L_YEAR_CUTOFF = 2002
|
||||||
|
|
||||||
|
# TODO: This is a placeholder methodology which isn't particularly scalable as more
|
||||||
|
# unusual floor descriptions are introduced
|
||||||
FLOOR_LEVELS = {
|
FLOOR_LEVELS = {
|
||||||
"Ground": 0,
|
"Ground": 0,
|
||||||
# We don't know what floor level, we just make sure it's not 0
|
# We don't know what floor level, we just make sure it's not 0
|
||||||
"mid floor": 1,
|
"mid floor": 1,
|
||||||
"NODATA!": None
|
"4th": 4
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, property_instance: Property, uvalue_estimates: UvalueEstimations):
|
def __init__(self, property_instance: Property, uvalue_estimates: UvalueEstimations):
|
||||||
|
|
@ -178,7 +180,10 @@ class FloorRecommendations(BaseUtility):
|
||||||
is_suspended = self.property.floor["is_suspended"]
|
is_suspended = self.property.floor["is_suspended"]
|
||||||
insulation_thickness = self.property.floor["insulation_thickness"]
|
insulation_thickness = self.property.floor["insulation_thickness"]
|
||||||
is_solid = self.property.floor["is_solid"]
|
is_solid = self.property.floor["is_solid"]
|
||||||
floor_level = self.FLOOR_LEVELS[self.property.data["floor-level"]]
|
floor_level = (
|
||||||
|
self.FLOOR_LEVELS[self.property.data["floor-level"]] if
|
||||||
|
self.property.data["floor-level"] not in self.DATA_ANOMALY_MATCHES else None
|
||||||
|
)
|
||||||
property_type = self.property.data["property-type"]
|
property_type = self.property.data["property-type"]
|
||||||
|
|
||||||
year_built = self.property.year_built
|
year_built = self.property.year_built
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,6 @@ from unittest.mock import Mock
|
||||||
from model_data.recommendations.FloorRecommendations import FloorRecommendations
|
from model_data.recommendations.FloorRecommendations import FloorRecommendations
|
||||||
|
|
||||||
|
|
||||||
# with open(
|
|
||||||
# os.path.abspath(os.path.dirname(__file__)) + "/model_data/tests/test_data/input_properties.pkl", "rb"
|
|
||||||
# ) as f:
|
|
||||||
# input_properties = pickle.load(f)
|
|
||||||
#
|
|
||||||
# with open(
|
|
||||||
# os.path.abspath(os.path.dirname(__file__)) + "/model_data/tests/test_data/uvalue_estimates.pkl", "rb"
|
|
||||||
# ) as f:
|
|
||||||
# uvalue_estimates = pickle.load(f)
|
|
||||||
|
|
||||||
|
|
||||||
class TestWallRecommendations:
|
class TestWallRecommendations:
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
@ -63,7 +52,55 @@ class TestWallRecommendations:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
recommender = FloorRecommendations(property_instance=input_properties[2], uvalue_estimates=uvalue_estimates)
|
recommender = FloorRecommendations(property_instance=input_properties[2], uvalue_estimates=uvalue_estimates)
|
||||||
|
assert recommender.estimated_u_value is None
|
||||||
recommender.recommend()
|
recommender.recommend()
|
||||||
assert recommender.property.floor["is_suspended"]
|
assert recommender.property.floor["is_suspended"]
|
||||||
assert recommended.es
|
assert recommender.estimated_u_value == 0.8766389420265843
|
||||||
assert recommender.recommendations
|
assert recommender.recommendations
|
||||||
|
|
||||||
|
types = {part["type"] for x in recommender.recommendations for part in x["parts"]}
|
||||||
|
|
||||||
|
assert types == {"suspended_floor_insulation"}
|
||||||
|
|
||||||
|
def test_uvalue_0_12(self, input_properties, uvalue_estimates):
|
||||||
|
"""
|
||||||
|
This is a home that doesn't have a property below but it's highly performant already and therefore
|
||||||
|
does not need floor insulation
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
recommender = FloorRecommendations(property_instance=input_properties[3], uvalue_estimates=uvalue_estimates)
|
||||||
|
assert recommender.estimated_u_value is None
|
||||||
|
recommender.recommend()
|
||||||
|
assert not recommender.property.floor["is_suspended"]
|
||||||
|
assert not recommender.property.floor["is_solid"]
|
||||||
|
assert recommender.estimated_u_value is None
|
||||||
|
assert not recommender.recommendations
|
||||||
|
|
||||||
|
def test_solid_no_insulation(self, input_properties, uvalue_estimates):
|
||||||
|
"""
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
recommender = FloorRecommendations(property_instance=input_properties[4], uvalue_estimates=uvalue_estimates)
|
||||||
|
assert recommender.estimated_u_value is None
|
||||||
|
recommender.recommend()
|
||||||
|
assert not recommender.property.floor["is_suspended"]
|
||||||
|
assert recommender.property.floor["is_solid"]
|
||||||
|
assert recommender.estimated_u_value == 0.7361642182695053
|
||||||
|
assert recommender.recommendations
|
||||||
|
|
||||||
|
types = {part["type"] for x in recommender.recommendations for part in x["parts"]}
|
||||||
|
|
||||||
|
assert types == {"solid_floor_insulation"}
|
||||||
|
|
||||||
|
def test_another_dwelling_below(self, input_properties, uvalue_estimates):
|
||||||
|
"""
|
||||||
|
This is another description we see when there is a property below
|
||||||
|
"""
|
||||||
|
input_properties[6].floor
|
||||||
|
recommender = FloorRecommendations(property_instance=input_properties[6], uvalue_estimates=uvalue_estimates)
|
||||||
|
assert recommender.estimated_u_value is None
|
||||||
|
recommender.recommend()
|
||||||
|
assert not recommender.property.floor["is_suspended"]
|
||||||
|
assert not recommender.property.floor["is_solid"]
|
||||||
|
assert recommender.estimated_u_value is None
|
||||||
|
assert not recommender.recommendations
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue