mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
import pytest
|
|
from epc_data.attributes.MainheatAttributes import MainHeatAttributes
|
|
from epc_data.tests.test_data.test_mainheat_attributes_cases import mainheat_cases
|
|
|
|
|
|
class TestMainHeatAttributes:
|
|
|
|
def test_init(self):
|
|
# Test initialization with a valid description
|
|
valid_description = 'Room heaters, electric, Room heaters, mains gas'
|
|
floor_attr = MainHeatAttributes(valid_description)
|
|
assert floor_attr.description == valid_description.lower()
|
|
|
|
# Test initialization with an empty description
|
|
with pytest.raises(ValueError):
|
|
MainHeatAttributes('')
|
|
|
|
# Test initialization with a description that contains none of the keywords
|
|
with pytest.raises(ValueError):
|
|
MainHeatAttributes('description without keywords')
|
|
|
|
def test_process_mainheat(self):
|
|
for test_case in mainheat_cases:
|
|
result = MainHeatAttributes(test_case['original_description']).process()
|
|
# Ensure the output ordering is correct
|
|
expected_result = {key: test_case[key] for key in result.keys()}
|
|
expected_result["desc"] = test_case["original_description"]
|
|
result["desc"] = test_case["original_description"]
|
|
assert result == expected_result
|
|
|
|
def test_invalid_description(self):
|
|
# Test that invalid descriptions raise a ValueError
|
|
invalid_descriptions = [
|
|
"",
|
|
"invalid description",
|
|
"description with no known heating types",
|
|
]
|
|
|
|
for description in invalid_descriptions:
|
|
with pytest.raises(ValueError):
|
|
MainHeatAttributes(description).process()
|