Added additional tests and fixed mainfuel test

This commit is contained in:
Khalim Conn-Kowlessar 2023-06-20 10:38:16 +01:00
parent 83b1f70616
commit e8181a9595
4 changed files with 18 additions and 2 deletions

View file

@ -90,6 +90,9 @@ class Property(BaseUtility):
if not cleaner.cleaned:
raise ValueError("Cleaner does not contain cleaned data")
if not self.data:
raise ValueError("Property does not contain data")
for description, attribute in cleaner.cleaned.items():
if self.data[description] in self.DATA_ANOMALY_MATCHES:

View file

@ -99,3 +99,5 @@ def handler():
p.get_components(cleaner)
# Now, given the components, we want to idenfity upgrade options
import pandas as pd
walls_df = pd.DataFrame([p.walls for p in input_properties])

View file

@ -63,11 +63,11 @@ class MainFuelAttributes(BaseUtility):
if self.nodata:
result = {
"fuel_type": None,
"fuel_type": self.UNKNOWN_FUEL,
"tariff_type": None,
"is_community": False,
"no_individual_heating_or_community_network": False,
"complex_fuel_type": False
"complex_fuel_type": None
}
return result

View file

@ -169,11 +169,22 @@ class TestProperty:
with pytest.raises(ValueError, match="Cleaner does not contain cleaned data"):
property_instance.get_components(mock_cleaner)
def test_get_components_no_data(self, property_instance, mock_cleaner):
# Modify the mock cleaner to have no attributes for a specific description
mock_cleaner.cleaned = {
"roof-description": []
}
# Verify that ValueError is raised when no attributes are found
with pytest.raises(ValueError, match="Property does not contain data"):
property_instance.get_components(mock_cleaner)
def test_get_components_no_attributes(self, property_instance, mock_cleaner):
# Modify the mock cleaner to have no attributes for a specific description
mock_cleaner.cleaned = {
"roof-description": []
}
property_instance.search_address_epc()
# Verify that ValueError is raised when no attributes are found
with pytest.raises(ValueError, match="Either No attributes or multiple found for roof-description"):