Model/epc_data/tests/test_clean_floor.py
2023-06-08 18:35:25 +01:00

72 lines
3.3 KiB
Python

import pytest
from epc_data.tests.test_data.EpcClean_test_floor_cases import clean_floor_cases
from epc_data.cleaning.Floor import CleanFloor
from unittest.mock import patch
class TestEpcClean:
class TestCleanFloor:
@patch('epc_data.cleaning.cleaning_utils.search_split_description')
def test_find_insulation_thickness_to_unheated_space(self, mock_search_split_description):
# Set up the mock to return a specific value
mock_search_split_description.return_value = 'average'
# clean_floor = CleanFloor('description to unheated space')
insulation_thickness = CleanFloor._find_insulation_thickness(
'to unheated space, insulated', True, False, False, False
)
assert insulation_thickness == 'average'
@patch('epc_data.cleaning.cleaning_utils.search_split_description')
def test_find_insulation_thickness_to_external_air(self, mock_search_split_description):
# Set up the mock to return a specific value
mock_search_split_description.return_value = 'below average'
# clean_floor = CleanFloor('To external air, limited insulation')
insulation_thickness = CleanFloor._find_insulation_thickness(
'to external air, limited insulation', False, True, False, False
)
assert insulation_thickness == 'below average'
@patch('epc_data.cleaning.cleaning_utils.search_split_description')
def test_find_insulation_thickness_is_suspended(self, mock_search_split_description):
# Set up the mock to return a specific value
mock_search_split_description.return_value = 'none'
# clean_floor = CleanFloor('description suspended')
insulation_thickness = CleanFloor._find_insulation_thickness(
'suspended, no insulation', False, False, True, False
)
assert insulation_thickness == 'none'
@patch('epc_data.cleaning.cleaning_utils.search_split_description')
def test_find_insulation_thickness_is_solid(self, mock_search_split_description):
# Set up the mock to return a specific value
mock_search_split_description.return_value = 'none'
# clean_floor = CleanFloor('description solid')
insulation_thickness = CleanFloor._find_insulation_thickness(
'solid, no insulation (assumed)', False, False, False, True
)
assert insulation_thickness == 'none'
def test_find_insulation_thickness_not_handled(self):
clean_floor = CleanFloor('description not handled')
with pytest.raises(NotImplementedError):
clean_floor._find_insulation_thickness(
'description not handled', False, False, False, False
)
def test_clean_floor(self):
for test_case in clean_floor_cases:
result = CleanFloor(test_case['original_description']).clean()
# 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