Added unit testing for hot water

This commit is contained in:
Khalim Conn-Kowlessar 2023-06-15 14:58:55 +01:00
parent 4967ea1e66
commit cee74f09e5
2 changed files with 154 additions and 0 deletions

View file

@ -0,0 +1,116 @@
hotwater_cases = [
{'original_description': 'Community scheme', 'heater_type': None, 'system_type': 'community scheme',
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': None,
'extra_features': None, 'chp_systems': None, 'distribution_system': None, 'no_system_present': None,
'assumed': False},
{'original_description': 'Community scheme with CHP', 'heater_type': None, 'system_type': 'community scheme',
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': None,
'extra_features': None, 'chp_systems': 'chp', 'distribution_system': None, 'no_system_present': None,
'assumed': False}, {'original_description': 'Community scheme, no cylinder thermostat', 'heater_type': None,
'system_type': 'community scheme', 'thermostat_characteristics': 'no cylinder thermostat',
'heating_scope': None, 'energy_recovery': None, 'tariff_type': None, 'extra_features': None,
'chp_systems': None, 'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'Community scheme, plus solar', 'heater_type': None, 'system_type': 'community scheme',
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': None,
'extra_features': 'plus solar', 'chp_systems': None, 'distribution_system': None, 'no_system_present': None,
'assumed': False}, {'original_description': 'Community scheme, waste water heat recovery', 'heater_type': None,
'system_type': 'community scheme', 'thermostat_characteristics': None, 'heating_scope': None,
'energy_recovery': 'waste water heat recovery', 'tariff_type': None, 'extra_features': None,
'chp_systems': None, 'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'Electric heat pump for water heating only', 'heater_type': 'electric heat pump',
'system_type': None, 'thermostat_characteristics': None, 'heating_scope': 'water heating only',
'energy_recovery': None, 'tariff_type': None, 'extra_features': None, 'chp_systems': None,
'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'Electric heat pump for water heating only, no cylinder thermostat',
'heater_type': 'electric heat pump', 'system_type': None, 'thermostat_characteristics': 'no cylinder thermostat',
'heating_scope': 'water heating only', 'energy_recovery': None, 'tariff_type': None, 'extra_features': None,
'chp_systems': None, 'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'Electric immersion, off-peak', 'heater_type': 'electric immersion', 'system_type': None,
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': 'off-peak',
'extra_features': None, 'chp_systems': None, 'distribution_system': None, 'no_system_present': None,
'assumed': False},
{'original_description': 'Electric immersion, off-peak, plus solar', 'heater_type': 'electric immersion',
'system_type': None, 'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None,
'tariff_type': 'off-peak', 'extra_features': 'plus solar', 'chp_systems': None, 'distribution_system': None,
'no_system_present': None, 'assumed': False},
{'original_description': 'Electric immersion, standard tariff', 'heater_type': 'electric immersion',
'system_type': None, 'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None,
'tariff_type': 'standard tariff', 'extra_features': None, 'chp_systems': None, 'distribution_system': None,
'no_system_present': None, 'assumed': False},
{'original_description': 'Electric immersion, standard tariff, flue gas heat recovery',
'heater_type': 'electric immersion', 'system_type': None, 'thermostat_characteristics': None,
'heating_scope': None, 'energy_recovery': 'flue gas heat recovery', 'tariff_type': 'standard tariff',
'extra_features': None, 'chp_systems': None, 'distribution_system': None, 'no_system_present': None,
'assumed': False},
{'original_description': 'Electric immersion, standard tariff, plus solar', 'heater_type': 'electric immersion',
'system_type': None, 'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None,
'tariff_type': 'standard tariff', 'extra_features': 'plus solar', 'chp_systems': None, 'distribution_system': None,
'no_system_present': None, 'assumed': False},
{'original_description': 'Electric immersion, standard tariff, waste water heat recovery',
'heater_type': 'electric immersion', 'system_type': None, 'thermostat_characteristics': None,
'heating_scope': None, 'energy_recovery': 'waste water heat recovery', 'tariff_type': 'standard tariff',
'extra_features': None, 'chp_systems': None, 'distribution_system': None, 'no_system_present': None,
'assumed': False},
{'original_description': 'Electric instantaneous at point of use', 'heater_type': 'electric instantaneous',
'system_type': None, 'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None,
'tariff_type': None, 'extra_features': None, 'chp_systems': None, 'distribution_system': None,
'no_system_present': None, 'assumed': False},
{'original_description': 'Electric instantaneous at point of use, waste water heat recovery',
'heater_type': 'electric instantaneous', 'system_type': None, 'thermostat_characteristics': None,
'heating_scope': None, 'energy_recovery': 'waste water heat recovery', 'tariff_type': None, 'extra_features': None,
'chp_systems': None, 'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'From main system', 'heater_type': None, 'system_type': 'from main system',
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': None,
'extra_features': None, 'chp_systems': None, 'distribution_system': None, 'no_system_present': None,
'assumed': False}, {'original_description': 'From main system, flue gas heat recovery', 'heater_type': None,
'system_type': 'from main system', 'thermostat_characteristics': None, 'heating_scope': None,
'energy_recovery': 'flue gas heat recovery', 'tariff_type': None, 'extra_features': None,
'chp_systems': None, 'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'From main system, no cylinder thermostat', 'heater_type': None,
'system_type': 'from main system', 'thermostat_characteristics': 'no cylinder thermostat', 'heating_scope': None,
'energy_recovery': None, 'tariff_type': None, 'extra_features': None, 'chp_systems': None,
'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'From main system, plus solar', 'heater_type': None, 'system_type': 'from main system',
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': None,
'extra_features': 'plus solar', 'chp_systems': None, 'distribution_system': None, 'no_system_present': None,
'assumed': False},
{'original_description': 'From main system, plus solar, waste water heat recovery', 'heater_type': None,
'system_type': 'from main system', 'thermostat_characteristics': None, 'heating_scope': None,
'energy_recovery': 'waste water heat recovery', 'tariff_type': None, 'extra_features': 'plus solar',
'chp_systems': None, 'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'From main system, waste water heat recovery', 'heater_type': None,
'system_type': 'from main system', 'thermostat_characteristics': None, 'heating_scope': None,
'energy_recovery': 'waste water heat recovery', 'tariff_type': None, 'extra_features': None, 'chp_systems': None,
'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'From secondary system', 'heater_type': None, 'system_type': 'from secondary system',
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': None,
'extra_features': None, 'chp_systems': None, 'distribution_system': None, 'no_system_present': None,
'assumed': False}, {'original_description': 'From secondary system, no cylinder thermostat', 'heater_type': None,
'system_type': 'from secondary system', 'thermostat_characteristics': 'no cylinder thermostat',
'heating_scope': None, 'energy_recovery': None, 'tariff_type': None, 'extra_features': None,
'chp_systems': None, 'distribution_system': None, 'no_system_present': None, 'assumed': False},
{'original_description': 'Gas boiler/circulator', 'heater_type': 'gas boiler', 'system_type': None,
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': None,
'extra_features': None, 'chp_systems': None, 'distribution_system': 'circulator', 'no_system_present': None,
'assumed': False},
{'original_description': 'Gas boiler/circulator, no cylinder thermostat', 'heater_type': 'gas boiler',
'system_type': None, 'thermostat_characteristics': 'no cylinder thermostat', 'heating_scope': None,
'energy_recovery': None, 'tariff_type': None, 'extra_features': None, 'chp_systems': None,
'distribution_system': 'circulator', 'no_system_present': None, 'assumed': False},
{'original_description': 'Gas instantaneous at point of use', 'heater_type': 'gas instantaneous',
'system_type': None, 'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None,
'tariff_type': None, 'extra_features': None, 'chp_systems': None, 'distribution_system': None,
'no_system_present': None, 'assumed': False},
{'original_description': 'Gas multipoint', 'heater_type': 'gas multipoint', 'system_type': None,
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None, 'tariff_type': None,
'extra_features': None, 'chp_systems': None, 'distribution_system': None, 'no_system_present': None,
'assumed': False},
{'original_description': 'Heat pump, waste water heat recovery', 'heater_type': 'heat pump', 'system_type': None,
'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': 'waste water heat recovery',
'tariff_type': None, 'extra_features': None, 'chp_systems': None, 'distribution_system': None,
'no_system_present': None, 'assumed': False},
{'original_description': 'No system present: electric immersion assumed', 'heater_type': 'electric immersion',
'system_type': None, 'thermostat_characteristics': None, 'heating_scope': None, 'energy_recovery': None,
'tariff_type': None, 'extra_features': None, 'chp_systems': None, 'distribution_system': None,
'no_system_present': 'no system present', 'assumed': True}
]

View file

@ -0,0 +1,38 @@
import pytest
from epc_data.attributes.HotWaterAttributes import HotWaterAttributes
from epc_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 types",
""
]
for description in invalid_descriptions:
with pytest.raises(ValueError):
HotWaterAttributes(description).process()