From 62b8df77ff0ddc2830cda7ad9f74d98ec30b252a Mon Sep 17 00:00:00 2001 From: Chiara Dinan Date: Thu, 14 Dec 2023 10:53:00 +0000 Subject: [PATCH 1/9] Revert "PC-533: Update ECO4 eligibility logic" This reverts commit 035ec1eee9bb10f7e637764676d344cab6d124ad. --- help_to_heat/frontdoor/eligibility.py | 30 +++++++-------- tests/test_eligibility.py | 55 ++++++++------------------- 2 files changed, 29 insertions(+), 56 deletions(-) diff --git a/help_to_heat/frontdoor/eligibility.py b/help_to_heat/frontdoor/eligibility.py index f38c5fcc..754c3e04 100644 --- a/help_to_heat/frontdoor/eligibility.py +++ b/help_to_heat/frontdoor/eligibility.py @@ -20,6 +20,8 @@ def calculate_eligibility(session_data): """ + Calculate which schemes the user is able to use. Based literally on the logic in the Mural file + (hence why it is illogical) :param session_data: :return: A tuple of which schemes the person is eligible for, if any """ @@ -28,34 +30,25 @@ def calculate_eligibility(session_data): country = session_data.get("country") benefits = session_data.get("benefits") property_type = session_data.get("property_type") - own_property = session_data.get("own_property") # "Scenario 0" if property_type == "Park home": return ("GBIS",) - # ECO4 and GBIS scenario 1 - home owner + # Scenario 1 if country in country_council_tax_bands: - if own_property in ("Yes, I own my property and live in it",): - if epc_rating in ("D", "E", "F", "G", "Not found"): - if benefits in ("Yes",): - return ("GBIS", "ECO4") - - # ECO4 and GBIS scenario 2 - private rented (tenant or landlord) - if country in country_council_tax_bands: - if own_property in ( - "No, I am a tenant", - "Yes, I am the property owner but I lease the property to one or more tenants", - ): + if council_tax_band in country_council_tax_bands[country]["eligible"]: if epc_rating in ("E", "F", "G", "Not found"): if benefits in ("Yes",): + logger.error("Scenario 1") return ("GBIS", "ECO4") - # ECO4 and GBIS scenario 3 - social housing tenant + # Scenario 2 if country in country_council_tax_bands: - if own_property in ("No, I am a social housing tenant",): - if epc_rating in ("D", "E", "F", "G", "Not found"): + if council_tax_band in country_council_tax_bands[country]["ineligible"]: + if epc_rating in ("E", "F", "G", "Not found"): if benefits in ("Yes",): + logger.error("Scenario 2") return ("GBIS", "ECO4") # Scenario 3 @@ -63,12 +56,14 @@ def calculate_eligibility(session_data): if council_tax_band in country_council_tax_bands[country]["eligible"]: if epc_rating in ("D", "E", "F", "G", "Not found"): if benefits in ("No",): + logger.error("Scenario 3a") return ("GBIS",) if country in country_council_tax_bands: if council_tax_band in country_council_tax_bands[country]["eligible"]: if epc_rating in ("D", "Not Found"): if benefits in ("Yes",): + logger.error("Scenario 3b") return ("GBIS",) # Scenario 3.1 @@ -76,6 +71,7 @@ def calculate_eligibility(session_data): if council_tax_band in country_council_tax_bands[country]["ineligible"]: if epc_rating in ("D", "Not Found"): if benefits in ("Yes",): + logger.error("Scenario 3.1") return ("GBIS",) # Scenario 4 @@ -83,6 +79,7 @@ def calculate_eligibility(session_data): if council_tax_band in country_council_tax_bands[country]["ineligible"]: if epc_rating in ("D", "E", "F", "G"): if benefits in ("No",): + logger.error("Scenario 4") return () # Scenario 5 @@ -90,6 +87,7 @@ def calculate_eligibility(session_data): if council_tax_band in country_council_tax_bands[country]["ineligible"]: if epc_rating in ("Not found"): if benefits in ("No",): + logger.error("Scenario 5") return () return () diff --git a/tests/test_eligibility.py b/tests/test_eligibility.py index fc165464..5cbbd17f 100644 --- a/tests/test_eligibility.py +++ b/tests/test_eligibility.py @@ -19,8 +19,9 @@ scenarios = ( ( { + "council_tax_band": "F", "benefits": "Yes", - "epc_rating": "D", + "epc_rating": "F", "country": "England", "own_property": "Yes, I own my property and live in it", }, @@ -28,8 +29,9 @@ ), ( { + "council_tax_band": "B", "benefits": "Yes", - "epc_rating": "G", + "epc_rating": "F", "country": "England", "own_property": "Yes, I own my property and live in it", }, @@ -37,19 +39,11 @@ ), ( { + "council_tax_band": "G", "benefits": "Yes", - "epc_rating": "D", - "country": "England", - "own_property": "No, I am a social housing tenant", - }, - "BOTH", - ), - ( - { - "benefits": "Yes", - "epc_rating": "E", + "epc_rating": "F", "country": "England", - "own_property": "No, I am a tenant", + "own_property": "Yes, I own my property and live in it", }, "BOTH", ), @@ -198,33 +192,14 @@ def test_eligibility_unknown_epc(): } -def test_eco4_scenario_1(): +def test_mural_scenario_1(): for country in eligible_council_tax: - for own_property in ("Yes, I own my property and live in it",): - for epc_rating in ("D", "E", "F", "G", "Not found"): - for benefits in ("Yes",): - session_data = { - "epc_rating": epc_rating, - "own_property": own_property, - "country": country, - "benefits": benefits, - } - result = calculate_eligibility(session_data) - expected = result_map["BOTH"] - assert result == expected - - -def test_eco4_scenario_2(): - for country in eligible_council_tax: - for own_property in ( - "No, I am a tenant", - "Yes, I am the property owner but I lease the property to one or more tenants", - ): - for epc_rating in ("E", "F", "G", "Not found"): + for council_tax_band in eligible_council_tax[country]["eligible"]: + for epc_rating in ("E", "F", "G"): for benefits in ("Yes",): session_data = { "epc_rating": epc_rating, - "own_property": own_property, + "council_tax_band": council_tax_band, "country": country, "benefits": benefits, } @@ -233,14 +208,14 @@ def test_eco4_scenario_2(): assert result == expected -def test_eco4_scenario_3(): +def test_mural_scenario_2(): for country in eligible_council_tax: - for own_property in ("No, I am a social housing tenant",): - for epc_rating in ("D", "E", "F", "G", "Not found"): + for council_tax_band in eligible_council_tax[country]["ineligible"]: + for epc_rating in ("E", "F", "G"): for benefits in ("Yes",): session_data = { "epc_rating": epc_rating, - "own_property": own_property, + "council_tax_band": council_tax_band, "country": country, "benefits": benefits, } From b5afa94f1826cbe821872a07e49446bc3ed888eb Mon Sep 17 00:00:00 2001 From: Sydney Wu Date: Tue, 19 Dec 2023 15:10:33 +0000 Subject: [PATCH 2/9] PC-580: Change feedback form link and fix test --- help_to_heat/templates/frontdoor/base.html | 2 +- tests/test_frontdoor.py | 73 ++-------------------- 2 files changed, 5 insertions(+), 70 deletions(-) diff --git a/help_to_heat/templates/frontdoor/base.html b/help_to_heat/templates/frontdoor/base.html index f76d056e..d87602e8 100644 --- a/help_to_heat/templates/frontdoor/base.html +++ b/help_to_heat/templates/frontdoor/base.html @@ -99,7 +99,7 @@