diff --git a/recommendations/tests/test_costs.py b/recommendations/tests/test_costs.py index ab822322..1f5b300c 100644 --- a/recommendations/tests/test_costs.py +++ b/recommendations/tests/test_costs.py @@ -1,6 +1,7 @@ from recommendations.Costs import Costs from unittest.mock import Mock import datetime +import pytest class TestCosts: @@ -499,3 +500,48 @@ class TestCosts: 'labour_hours': 24.79, 'labour_days': 1.549375, 'labour_cost': 186.9032} assert costs.labour_adjustment_factor == 0.88 + + # Mock property instance for regional tests + @pytest.fixture(params=[ + ("Northamptonshire", "East Midlands", 7927.44), + ("Greater London Authority", "Inner London", 10475.0), + ("Adur", "South East England", 8333.32), + ("Bournemouth", "South West England", 8452), + ("Basildon", "East of England", 7895.44), + ("Birmingham", "West Midlands", 7706.2), + ("County Durham", "North East England", 8113.96), + ("Allerdale", "North West England", 6481.68), + ("York", "Yorkshire and the Humber", 8243.6), + ("Cardiff", "Wales", 7595.32), + ("Glasgow City", "Scotland", 7871.88), + ("Belfast", "Northern Ireland", 8504.36) + ]) + def mock_property_with_region(self, request): + county, region, expected_cost = request.param + mock_property = Mock() + mock_property.data = {"county": county} + return mock_property, region, expected_cost + + # Test for different wattages + @pytest.mark.parametrize("wattage, expected_cost", [ + (3000, 5945.58), + (4000, 7927.44), + (5000, 9909.3), + (6000, 11891.16), + ]) + def test_solar_pv_different_wattages(self, wattage, expected_cost): + mock_property = Mock() + mock_property.data = {"county": "Mansfield"} + costs = Costs(mock_property) + result = costs.solar_pv(wattage) + assert result['total'] == pytest.approx(expected_cost, rel=0.01) + + def test_solar_pv_regional_variation(self, mock_property_with_region): + # Test for regional cost variations + property_instance, expected_region, expected_cost = mock_property_with_region + costs = Costs(property_instance) + + assert costs.region == expected_region + + result = costs.solar_pv(4000) # Testing with a fixed wattage of 4000 + assert result['total'] == pytest.approx(expected_cost, rel=0.01)