mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
completed tests
This commit is contained in:
parent
3d395ed5bb
commit
11d26720c9
4 changed files with 52 additions and 2 deletions
4
Makefile
Normal file
4
Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.PHONY: epc_data_test
|
||||
|
||||
epc_data_test_attributes:
|
||||
pytest --cov-report term-missing --cov=epc_data/attributes
|
||||
|
|
@ -5,4 +5,4 @@ pandas
|
|||
mypy
|
||||
pytest
|
||||
mock
|
||||
nltk
|
||||
pytest-cov
|
||||
|
|
@ -1,10 +1,25 @@
|
|||
import pytest
|
||||
from epc_data.tests.test_data.test_floor_attributes_cases import clean_floor_cases
|
||||
from epc_data.attributes.FloorAttributes import FloorAttributes
|
||||
|
||||
|
||||
class TestCleanFloor:
|
||||
|
||||
def test_clean_floor(self):
|
||||
def test_init(self):
|
||||
# Test initialization with a valid description
|
||||
valid_description = 'Solid, limited insulation (assumed)'
|
||||
floor_attr = FloorAttributes(valid_description)
|
||||
assert floor_attr.description == valid_description.lower()
|
||||
|
||||
# Test initialization with an empty description
|
||||
with pytest.raises(ValueError):
|
||||
FloorAttributes('')
|
||||
|
||||
# Test initialization with a description that contains none of the keywords
|
||||
with pytest.raises(ValueError):
|
||||
FloorAttributes('description without keywords')
|
||||
|
||||
def test_process_floor(self):
|
||||
for test_case in clean_floor_cases:
|
||||
result = FloorAttributes(test_case['original_description']).process()
|
||||
# Ensure the output ordering is correct
|
||||
|
|
@ -12,3 +27,21 @@ class TestCleanFloor:
|
|||
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 floor types or thermal transmittance",
|
||||
]
|
||||
|
||||
for description in invalid_descriptions:
|
||||
with pytest.raises(ValueError):
|
||||
FloorAttributes(description).process()
|
||||
|
||||
def test_process_with_invalid_description(self):
|
||||
# Test that processing an invalid description raises a ValueError
|
||||
invalid_description = 'description without keywords'
|
||||
with pytest.raises(ValueError):
|
||||
FloorAttributes(invalid_description)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,19 @@ else:
|
|||
|
||||
class TestRoofAttributes:
|
||||
|
||||
def test_init(self):
|
||||
# Test initialization with a valid description
|
||||
valid_description = "(Another dwelling above)"
|
||||
floor_attr = RoofAttributes(valid_description)
|
||||
assert floor_attr.description == valid_description.lower()
|
||||
|
||||
# Test initialization with an empty description
|
||||
with pytest.raises(ValueError):
|
||||
RoofAttributes('')
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
RoofAttributes('description without keywords')
|
||||
|
||||
def test_clean_roof(self):
|
||||
result = RoofAttributes('Pitched, 270 mm loft insulation').process()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue