import pandas as pd import pytest from model_data.tests.test_data.test_lighting_attributes_cases import test_cases from model_data.epc_attributes.LightingAttributes import LightingAttributes # An example averages dataset to use in tests. It is a dictionary where the key is a lighting description and the # value is the expected proportion. averages = pd.DataFrame( [ {"lighting-description": "good lighting efficiency", "low-energy-lighting": 0.75}, {"lighting-description": "excellent lighting efficiency", "low-energy-lighting": 1.0}, {"lighting-description": "below average lighting efficiency", "low-energy-lighting": 0.25} ] ) class TestLightingAttributes: def test_no_lighting(self): lighting = LightingAttributes("no low energy lighting", averages) result = lighting.process() assert result == {"low_energy_proportion": 0} def test_all_outlets(self): lighting = LightingAttributes("Low energy lighting in all fixed outlets", averages) result = lighting.process() assert result == {"low_energy_proportion": 1} def test_good_efficiency(self): lighting = LightingAttributes("Good lighting efficiency", averages) result = lighting.process() assert result == {"low_energy_proportion": 0.75} def test_excellent_efficiency(self): lighting = LightingAttributes("Excellent lighting efficiency", averages) result = lighting.process() assert result == {"low_energy_proportion": 1} def test_below_average_efficiency(self): lighting = LightingAttributes("Below average lighting efficiency", averages) result = lighting.process() assert result == {"low_energy_proportion": 0.25} def test_percentage(self): lighting = LightingAttributes("Low energy lighting in 50% of fixed outlets", averages) result = lighting.process() assert result == {"low_energy_proportion": 0.5} def test_unknown_description(self): with pytest.raises(NotImplementedError): LightingAttributes("This is an unknown description", averages).process() @pytest.mark.parametrize( "test_case", test_cases ) def test_process_mainheat(self, test_case): expected_result = test_case.copy() del expected_result["original_description"] result = LightingAttributes(test_case['original_description'], averages).process() assert sorted(result.items()) == sorted(expected_result.items())