Added window tests, refactored wall tests

This commit is contained in:
Khalim Conn-Kowlessar 2023-06-14 11:36:48 +01:00
parent 450b81cb14
commit 06594bb1bb
2 changed files with 48 additions and 8 deletions

View file

@ -40,11 +40,21 @@ class TestWallAttributes:
assert result['internal_insulation'] is True
assert result['external_insulation'] is False
def test_wall_attributes(self):
for test_case in wall_cases:
result = WallAttributes(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
@pytest.mark.parametrize(
"test_case",
wall_cases
)
def test_wall_attributes(self, test_case):
expected_result = test_case.copy()
del expected_result["original_description"]
result = WallAttributes(test_case['original_description']).process()
assert set(result.keys()) == {
'is_as_built', 'is_assumed', 'is_sandstone_or_limestone', 'thermal_transmittance',
'is_cavity_wall', 'is_filled_cavity', 'is_system_built',
'external_insulation', 'is_solid_brick', 'is_timber_frame', 'internal_insulation',
'is_cob', 'is_granite_or_whinstone', 'insulation_thickness',
'thermal_transmittance_unit'
}
# Ensure the output ordering is correct
assert sorted(result.items()) == sorted(expected_result.items())

View file

@ -0,0 +1,30 @@
import pytest
from epc_data.attributes.WindowAttributes import WindowAttributes
from epc_data.tests.test_data.test_window_attributes_cases import windows_cases
class TestWindowAttributes:
def test_init(self):
# Test initialization with a valid description
valid_description = 'fully glazed, triple glazing'
window_attr = WindowAttributes(valid_description)
assert window_attr.description == valid_description.lower()
# Test initialization with an empty description
empty_description = ''
window_attr_empty = WindowAttributes(empty_description)
assert window_attr_empty.nodata
# Test initialization with a description that contains none of the keywords
with pytest.raises(ValueError):
WindowAttributes('description without keywords')
@pytest.mark.parametrize(
"case",
windows_cases
)
def test_process(self, case):
output = WindowAttributes(case['original_description']).process()
expected_output = {key: case[key] for key in output.keys()}
assert output == expected_output