Allow empty roof description

This commit is contained in:
Khalim Conn-Kowlessar 2023-07-01 16:50:27 +01:00
parent 0f12f9cae4
commit a4d4e09680
2 changed files with 7 additions and 5 deletions

View file

@ -16,7 +16,7 @@ class RoofAttributes(BaseUtility):
self.description: str = description.lower()
self.nodata = not description or description in self.DATA_ANOMALY_MATCHES
if not description or not any(
if not self.nodata and not any(
rt in self.description for rt in self.ROOF_TYPES + self.DWELLING_ABOVE + ["average thermal transmittance"]
):
raise ValueError('Invalid description')

View file

@ -22,8 +22,8 @@ class TestRoofAttributes:
assert floor_attr.description == valid_description.lower()
# Test initialization with an empty description
with pytest.raises(ValueError):
RoofAttributes('')
ra = RoofAttributes('')
assert ra.nodata
with pytest.raises(ValueError):
RoofAttributes('description without keywords')
@ -85,11 +85,13 @@ class TestRoofAttributes:
assert result[k] == expected_output[k]
def test_clean_roof_invalid(self):
with pytest.raises(ValueError):
RoofAttributes('').process()
with pytest.raises(ValueError):
RoofAttributes('nonsense string').process()
def test_clean_roof_no_description(self):
roof = RoofAttributes('').process()
assert roof == {}
def test_clean_roof_edge_cases(self):
# Insulation thickness edge case
assert RoofAttributes('Pitched, 99999 mm loft insulation').process()['insulation_thickness'] == "99999"