diff --git a/model_data/Property.py b/model_data/Property.py index 1de3577b..df624130 100644 --- a/model_data/Property.py +++ b/model_data/Property.py @@ -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: diff --git a/model_data/app.py b/model_data/app.py index 62d4fc4b..c6968009 100644 --- a/model_data/app.py +++ b/model_data/app.py @@ -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]) diff --git a/model_data/epc_attributes/MainFuelAttributes.py b/model_data/epc_attributes/MainFuelAttributes.py index 238c53ab..96749944 100644 --- a/model_data/epc_attributes/MainFuelAttributes.py +++ b/model_data/epc_attributes/MainFuelAttributes.py @@ -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 diff --git a/model_data/tests/test_property.py b/model_data/tests/test_property.py index 8870a1f4..6ae90316 100644 --- a/model_data/tests/test_property.py +++ b/model_data/tests/test_property.py @@ -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"):