fixed bug with conservation area and added test

This commit is contained in:
Khalim Conn-Kowlessar 2023-12-05 15:04:08 +00:00
parent bf6020026a
commit afeac56f5e
2 changed files with 32 additions and 1 deletions

View file

@ -369,7 +369,8 @@ class Property(Definitions):
self.is_listed = spatial["is_listed_building"].values[0]
self.is_heritage = spatial["is_heritage_building"].values[0]
if self.in_conservation_area is True | self.is_listed is True | self.is_heritage is True:
# We do an equals True, in the case of one of these variables being True
if (self.in_conservation_area == True) | (self.is_listed == True) | (self.is_heritage == True):
self.restricted_measures = True
spatial_dict = spatial.to_dict("records")[0]

View file

@ -1,3 +1,4 @@
import pandas as pd
import pytest
from unittest.mock import Mock
from epc_api.client import EpcClient
@ -345,3 +346,32 @@ class TestProperty:
# Verify that ValueError is raised when multiple attributes are found
with pytest.raises(ValueError, match="Either No attributes or multiple found for roof-description"):
property_instance.get_components(cleaned)
def test_set_spatial(self, mock_epc_client):
prop = Property(1, "AB12CD", "Test Address", mock_epc_client)
spatial1 = pd.DataFrame([{
'X_COORDINATE': 411143.0, 'Y_COORDINATE': 281701.0, 'LATITUDE': 52.4331896, 'LONGITUDE': -1.8375238,
'conservation_status': True, 'is_listed_building': False, 'is_heritage_building': True
}])
prop.set_spatial(spatial1)
assert prop.in_conservation_area
assert not prop.is_listed
assert prop.is_heritage
assert prop.restricted_measures
prop2 = Property(1, "AB12CD", "Test Address", mock_epc_client)
spatial2 = pd.DataFrame([{
'X_COORDINATE': 411143.0, 'Y_COORDINATE': 281701.0, 'LATITUDE': 52.4331896, 'LONGITUDE': -1.8375238,
'conservation_status': None, 'is_listed_building': False, 'is_heritage_building': False
}])
prop2.set_spatial(spatial2)
assert prop2.in_conservation_area is None
assert not prop2.is_listed
assert not prop2.is_heritage
assert not prop2.restricted_measures