mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
map empty description to null outputs for Roof Attributes and updated tests. Removed redundant repeat test
This commit is contained in:
parent
866166c022
commit
9e6ff3e48d
3 changed files with 11 additions and 14 deletions
|
|
@ -74,6 +74,8 @@ class RoofAttributes(Definitions):
|
||||||
"insulation_thickness",
|
"insulation_thickness",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
NODATA_NULLS = ["insulation_thickness", "thermal_transmittance", "thermal_transmittance_unit"]
|
||||||
|
|
||||||
def __init__(self, description: str):
|
def __init__(self, description: str):
|
||||||
"""
|
"""
|
||||||
:param description: Description of the roof.
|
:param description: Description of the roof.
|
||||||
|
|
@ -153,6 +155,10 @@ class RoofAttributes(Definitions):
|
||||||
if self.nodata:
|
if self.nodata:
|
||||||
for key in self.DEFAULT_KEYS:
|
for key in self.DEFAULT_KEYS:
|
||||||
result[key] = False
|
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
|
return result
|
||||||
|
|
||||||
description = self.description
|
description = self.description
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ class TestRoofAttributes:
|
||||||
def test_empty_str(self):
|
def test_empty_str(self):
|
||||||
# Test initialization with an empty description
|
# Test initialization with an empty description
|
||||||
assert RoofAttributes('').process() == {
|
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_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}
|
assert set(list(RoofAttributes('').process().values())) == {False}
|
||||||
|
|
||||||
|
|
@ -92,15 +92,6 @@ class TestRoofAttributes:
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
RoofAttributes('nonsense string').process()
|
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):
|
def test_clean_roof_edge_cases(self):
|
||||||
# Insulation thickness edge case
|
# Insulation thickness edge case
|
||||||
assert RoofAttributes('Pitched, 99999 mm loft insulation').process()['insulation_thickness'] == "99999"
|
assert RoofAttributes('Pitched, 99999 mm loft insulation').process()['insulation_thickness'] == "99999"
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ class RoofRecommendations:
|
||||||
|
|
||||||
# Extract the insulation thickness from the roof, which is used throughout this method
|
# Extract the insulation thickness from the roof, which is used throughout this method
|
||||||
self.insulation_thickness = convert_thickness_to_numeric(
|
self.insulation_thickness = convert_thickness_to_numeric(
|
||||||
self.property.roof["insulation_thickness"],
|
string_thickness=self.property.roof["insulation_thickness"],
|
||||||
self.property.roof["is_pitched"],
|
is_pitched=self.property.roof["is_pitched"],
|
||||||
self.property.roof["is_flat"]
|
is_flat=self.property.roof["is_flat"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue