mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
import pytest
|
|
from model_data.epc_attributes.MainheatControlAttributes import MainheatControlAttributes
|
|
from model_data.tests.test_data.test_mainheat_control_attributes_cases import mainheat_control_cases
|
|
|
|
|
|
class TestMainHeatControlAttributes:
|
|
|
|
def test_init(self):
|
|
# Test initialization with a valid description
|
|
valid_description = 'Flat rate charging, no thermostatic control of room temperature'
|
|
attr = MainheatControlAttributes(valid_description)
|
|
assert attr.description == valid_description.lower()
|
|
|
|
# Test initialization with an empty description
|
|
with pytest.raises(ValueError):
|
|
MainheatControlAttributes('')
|
|
|
|
# Test initialization with a description that contains none of the keywords
|
|
with pytest.raises(ValueError):
|
|
MainheatControlAttributes('description without keywords')
|
|
|
|
@pytest.mark.parametrize(
|
|
"test_case",
|
|
mainheat_control_cases
|
|
)
|
|
def test_process_mainheat(self, test_case):
|
|
expected_result = test_case.copy()
|
|
del expected_result["original_description"]
|
|
result = MainheatControlAttributes(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 heating control types",
|
|
]
|
|
|
|
for description in invalid_descriptions:
|
|
with pytest.raises(ValueError):
|
|
MainheatControlAttributes(description).process()
|