import pytest from model_data.epc_attributes.HotWaterAttributes import HotWaterAttributes from model_data.tests.test_data.test_hot_water_attributes_cases import hotwater_cases class TestHotWaterAttributes: def test_init(self): # Test initialization with a valid description valid_description = 'Electric heat pump for water heating only, no cylinder thermostat' attr = HotWaterAttributes(valid_description) assert attr.description == 'electric heat pump for water heating only, no cylinder thermostat' # Test initialization with a description that contains none of the keywords with pytest.raises(ValueError): HotWaterAttributes('description without keywords') @pytest.mark.parametrize( "test_case", hotwater_cases ) def test_process_mainheat(self, test_case): expected_result = test_case.copy() del expected_result["original_description"] result = HotWaterAttributes(test_case['original_description']).process() assert sorted(result.items()) == sorted(expected_result.items()) def test_invalid_description(self): # Test that invalid descriptions raise a ValueError invalid_descriptions = [ "invalid description", "description with no known hotwater data_types", "" ] for description in invalid_descriptions: with pytest.raises(ValueError): HotWaterAttributes(description).process()