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 @@ {{_("Cookies we are usi
{{_("This is a new service – your ")}}{{_("feedback")}}{{_(" will help us to improve it.")}}
diff --git a/tests/test_frontdoor.py b/tests/test_frontdoor.py
index 5ed470aa..917c01b9 100644
--- a/tests/test_frontdoor.py
+++ b/tests/test_frontdoor.py
@@ -642,26 +642,7 @@ def test_feedback_no_session():
page = client.get("/start")
page = page.follow()
page = page.click(contains="feedback")
- form = page.get_form()
- form["satisfaction"] = "Somewhat satisfied"
- form["usage-reason"] = "To find ways to reduce my energy bills"
- form["guidance"] = "Agree"
- form["accuracy"] = "Neutral"
- form["advice"] = "Agree"
- form["more-detail"] = "Improvement comment"
- page = form.submit().follow()
-
- assert page.has_one("h1:contains('Thank you for your feedback')")
- assert not page.all("a:contains('Back')")
-
- feedback = frontdoor_models.Feedback.objects.latest("created_at")
- assert feedback.data["satisfaction"] == "Somewhat satisfied"
- assert feedback.data["usage-reason"] == "To find ways to reduce my energy bills"
- assert feedback.data["guidance"] == "Agree"
- assert feedback.data["accuracy"] == "Neutral"
- assert feedback.data["advice"] == "Agree"
- assert feedback.data["more-detail"] == "Improvement comment"
-
+ assert "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
def test_feedback_with_session():
client = utils.get_client()
@@ -682,31 +663,7 @@ def test_feedback_with_session():
assert page.has_one("h1:contains('Do you own the property?')")
page = page.click(contains="feedback")
- form = page.get_form()
- form["satisfaction"] = "Somewhat satisfied"
- form["usage-reason"] = "To find ways to reduce my energy bills"
- form["guidance"] = "Agree"
- form["accuracy"] = "Neutral"
- form["advice"] = "Agree"
- form["more-detail"] = "Improvement comment"
-
- page = form.submit().follow()
-
- assert page.has_one("h1:contains('Thank you for your feedback')")
-
- feedback = frontdoor_models.Feedback.objects.latest("created_at")
- assert feedback.data["satisfaction"] == "Somewhat satisfied"
- assert feedback.data["usage-reason"] == "To find ways to reduce my energy bills"
- assert feedback.data["guidance"] == "Agree"
- assert feedback.data["accuracy"] == "Neutral"
- assert feedback.data["advice"] == "Agree"
- assert feedback.data["more-detail"] == "Improvement comment"
-
- feedback_session_id = page.path.split("/")[3]
- assert uuid.UUID(feedback_session_id)
-
- page = page.click(contains="Return to your application")
- assert page.has_one("h1:contains('Do you own the property?')")
+ assert "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
def test_feedback_validation_with_session_no_answers():
@@ -728,13 +685,7 @@ def test_feedback_validation_with_session_no_answers():
assert page.has_one("h1:contains('Do you own the property?')")
page = page.click(contains="feedback")
- form = page.get_form()
-
- page = form.submit()
-
- assert page.has_one("h1:contains('Help us improve the service')")
- assert page.has_one("h2:contains('There is a problem')")
- assert page.has_one("a:contains('Please answer at least one question before submitting feedback')")
+ assert "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
def test_feedback_validation_with_session_two_answers():
@@ -756,23 +707,7 @@ def test_feedback_validation_with_session_two_answers():
assert page.has_one("h1:contains('Do you own the property?')")
page = page.click(contains="feedback")
- form = page.get_form()
- form["satisfaction"] = "Somewhat satisfied"
- form["more-detail"] = "Improvement comment"
-
- page = form.submit().follow()
-
- assert page.has_one("h1:contains('Thank you for your feedback')")
-
- feedback = frontdoor_models.Feedback.objects.latest("created_at")
- assert feedback.data["satisfaction"] == "Somewhat satisfied"
- assert feedback.data["more-detail"] == "Improvement comment"
-
- feedback_session_id = page.path.split("/")[3]
- assert uuid.UUID(feedback_session_id)
-
- page = page.click(contains="Return to your application")
- assert page.has_one("h1:contains('Do you own the property?')")
+ assert "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
def test_privacy_policy_with_session():
From 489f0e06f66789c18c41d07b95afe308304ac4e1 Mon Sep 17 00:00:00 2001
From: Sydney Wu
Date: Tue, 19 Dec 2023 15:34:06 +0000
Subject: [PATCH 3/9] PC-580: Formatting
---
tests/test_frontdoor.py | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/tests/test_frontdoor.py b/tests/test_frontdoor.py
index 917c01b9..ef86e9eb 100644
--- a/tests/test_frontdoor.py
+++ b/tests/test_frontdoor.py
@@ -3,7 +3,6 @@
import uuid
from help_to_heat.frontdoor import interface
-from help_to_heat.frontdoor import models as frontdoor_models
from help_to_heat.frontdoor.mock_os_api import EmptyOSApi, MockOSApi
from help_to_heat.portal import models
@@ -642,7 +641,11 @@ def test_feedback_no_session():
page = client.get("/start")
page = page.follow()
page = page.click(contains="feedback")
- assert "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
+ assert (
+ "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_"
+ "oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
+ )
+
def test_feedback_with_session():
client = utils.get_client()
@@ -663,7 +666,10 @@ def test_feedback_with_session():
assert page.has_one("h1:contains('Do you own the property?')")
page = page.click(contains="feedback")
- assert "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
+ assert (
+ "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_"
+ "oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
+ )
def test_feedback_validation_with_session_no_answers():
@@ -685,7 +691,10 @@ def test_feedback_validation_with_session_no_answers():
assert page.has_one("h1:contains('Do you own the property?')")
page = page.click(contains="feedback")
- assert "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
+ assert (
+ "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_"
+ "oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
+ )
def test_feedback_validation_with_session_two_answers():
@@ -707,7 +716,10 @@ def test_feedback_validation_with_session_two_answers():
assert page.has_one("h1:contains('Do you own the property?')")
page = page.click(contains="feedback")
- assert "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
+ assert (
+ "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_"
+ "oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
+ )
def test_privacy_policy_with_session():
From 0e87a52cd4bd9563b1effc07b1c5fb3a325c98cb Mon Sep 17 00:00:00 2001
From: Sydney Wu
Date: Thu, 21 Dec 2023 16:25:58 +0000
Subject: [PATCH 4/9] PC-580: Remove unused tests
---
tests/test_frontdoor.py | 104 +---------------------------------------
1 file changed, 1 insertion(+), 103 deletions(-)
diff --git a/tests/test_frontdoor.py b/tests/test_frontdoor.py
index ef86e9eb..b9e6a33b 100644
--- a/tests/test_frontdoor.py
+++ b/tests/test_frontdoor.py
@@ -636,7 +636,7 @@ def test_referral_email():
referral.delete()
-def test_feedback_no_session():
+def test_feedback():
client = utils.get_client()
page = client.get("/start")
page = page.follow()
@@ -647,108 +647,6 @@ def test_feedback_no_session():
)
-def test_feedback_with_session():
- client = utils.get_client()
- page = client.get("/start")
- page = page.follow()
-
- session_id = page.path.split("/")[1]
- assert uuid.UUID(session_id)
-
- form = page.get_form()
- form["country"] = "Scotland"
- page = form.submit().follow()
-
- form = page.get_form()
- form["supplier"] = "Utilita"
- page = form.submit().follow()
-
- assert page.has_one("h1:contains('Do you own the property?')")
-
- page = page.click(contains="feedback")
- assert (
- "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_"
- "oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
- )
-
-
-def test_feedback_validation_with_session_no_answers():
- client = utils.get_client()
- page = client.get("/start")
- page = page.follow()
-
- session_id = page.path.split("/")[1]
- assert uuid.UUID(session_id)
-
- form = page.get_form()
- form["country"] = "Scotland"
- page = form.submit().follow()
-
- form = page.get_form()
- form["supplier"] = "Utilita"
- page = form.submit().follow()
-
- assert page.has_one("h1:contains('Do you own the property?')")
-
- page = page.click(contains="feedback")
- assert (
- "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_"
- "oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
- )
-
-
-def test_feedback_validation_with_session_two_answers():
- client = utils.get_client()
- page = client.get("/start")
- page = page.follow()
-
- session_id = page.path.split("/")[1]
- assert uuid.UUID(session_id)
-
- form = page.get_form()
- form["country"] = "Scotland"
- page = form.submit().follow()
-
- form = page.get_form()
- form["supplier"] = "Utilita"
- page = form.submit().follow()
-
- assert page.has_one("h1:contains('Do you own the property?')")
-
- page = page.click(contains="feedback")
- assert (
- "https://forms.office.com/Pages/ResponsePage.aspx?id=BXCsy8EC60O0l-ZJLRst2JbIaLaL_"
- "oJOivXjaXYvCetUMFRBRVcyWkk4TzhYU0E4NjQzWlZMWThRMC4u" in page.url
- )
-
-
-def test_privacy_policy_with_session():
- client = utils.get_client()
- page = client.get("/start")
- page = page.follow()
-
- session_id = page.path.split("/")[1]
- assert uuid.UUID(session_id)
-
- form = page.get_form()
- form["country"] = "Scotland"
- page = form.submit().follow()
-
- form = page.get_form()
- form["supplier"] = "Utilita"
- page = form.submit().follow()
-
- assert page.has_one("h1:contains('Do you own the property?')")
-
- page = page.click(contains="Privacy Policy")
-
- privacy_policy_session_id = page.path.split("/")[2]
- assert uuid.UUID(privacy_policy_session_id)
-
- page = page.click(contains="Back")
- assert page.has_one("h1:contains('Do you own the property?')")
-
-
def test_accessibility_statement_with_session():
client = utils.get_client()
page = client.get("/start")
From f1d54d0769a718771a01af6af8b2068fd23c734b Mon Sep 17 00:00:00 2001
From: Ladun Omideyi
Date: Thu, 4 Jan 2024 12:48:14 +0000
Subject: [PATCH 5/9] PC-NONE: Revert eligibility.py and test_eligibility.py to
prior eligibility logic
---
help_to_heat/frontdoor/eligibility.py | 22 +++++++----
tests/test_eligibility.py | 54 +++++++++++++++++++--------
2 files changed, 54 insertions(+), 22 deletions(-)
diff --git a/help_to_heat/frontdoor/eligibility.py b/help_to_heat/frontdoor/eligibility.py
index 754c3e04..088634aa 100644
--- a/help_to_heat/frontdoor/eligibility.py
+++ b/help_to_heat/frontdoor/eligibility.py
@@ -35,20 +35,28 @@ def calculate_eligibility(session_data):
if property_type == "Park home":
return ("GBIS",)
- # Scenario 1
+ # ECO4 and GBIS scenario 1 - home owner
if country in country_council_tax_bands:
- if council_tax_band in country_council_tax_bands[country]["eligible"]:
- if epc_rating in ("E", "F", "G", "Not found"):
+ 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",):
- logger.error("Scenario 1")
return ("GBIS", "ECO4")
- # Scenario 2
+ # ECO4 and GBIS scenario 2 - private rented (tenant or landlord)
if country in country_council_tax_bands:
- if council_tax_band in country_council_tax_bands[country]["ineligible"]:
+ 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 epc_rating in ("E", "F", "G", "Not found"):
if benefits in ("Yes",):
- logger.error("Scenario 2")
+ return ("GBIS", "ECO4")
+
+ # ECO4 and GBIS scenario 3 - social housing tenant
+ 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 benefits in ("Yes",):
return ("GBIS", "ECO4")
# Scenario 3
diff --git a/tests/test_eligibility.py b/tests/test_eligibility.py
index 5cbbd17f..9ae4856c 100644
--- a/tests/test_eligibility.py
+++ b/tests/test_eligibility.py
@@ -19,9 +19,8 @@
scenarios = (
(
{
- "council_tax_band": "F",
"benefits": "Yes",
- "epc_rating": "F",
+ "epc_rating": "D",
"country": "England",
"own_property": "Yes, I own my property and live in it",
},
@@ -29,9 +28,8 @@
),
(
{
- "council_tax_band": "B",
"benefits": "Yes",
- "epc_rating": "F",
+ "epc_rating": "G",
"country": "England",
"own_property": "Yes, I own my property and live in it",
},
@@ -39,11 +37,19 @@
),
(
{
- "council_tax_band": "G",
"benefits": "Yes",
- "epc_rating": "F",
+ "epc_rating": "D",
"country": "England",
- "own_property": "Yes, I own my property and live in it",
+ "own_property": "No, I am a social housing tenant",
+ },
+ "BOTH",
+ ),
+ (
+ {
+ "benefits": "Yes",
+ "epc_rating": "E",
+ "country": "England",
+ "own_property": "No, I am a tenant",
},
"BOTH",
),
@@ -192,14 +198,14 @@ def test_eligibility_unknown_epc():
}
-def test_mural_scenario_1():
+def test_eco4_scenario_1():
for country in eligible_council_tax:
- for council_tax_band in eligible_council_tax[country]["eligible"]:
- for epc_rating in ("E", "F", "G"):
+ 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,
- "council_tax_band": council_tax_band,
+ "own_property": own_property,
"country": country,
"benefits": benefits,
}
@@ -208,14 +214,32 @@ def test_mural_scenario_1():
assert result == expected
-def test_mural_scenario_2():
+def test_eco4_scenario_2():
for country in eligible_council_tax:
- for council_tax_band in eligible_council_tax[country]["ineligible"]:
- for epc_rating in ("E", "F", "G"):
+ 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 benefits in ("Yes",):
session_data = {
"epc_rating": epc_rating,
- "council_tax_band": council_tax_band,
+ "own_property": own_property,
+ "country": country,
+ "benefits": benefits,
+ }
+ result = calculate_eligibility(session_data)
+ expected = result_map["BOTH"]
+ assert result == expected
+
+def test_eco4_scenario_3():
+ 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 benefits in ("Yes",):
+ session_data = {
+ "epc_rating": epc_rating,
+ "own_property": own_property,
"country": country,
"benefits": benefits,
}
From 23db9cc112fa7365aae116964b97d3e1fd2275b9 Mon Sep 17 00:00:00 2001
From: Ladun Omideyi
Date: Thu, 4 Jan 2024 14:01:48 +0000
Subject: [PATCH 6/9] PC-NONE: Add back own property definition
---
help_to_heat/frontdoor/eligibility.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/help_to_heat/frontdoor/eligibility.py b/help_to_heat/frontdoor/eligibility.py
index 088634aa..1dfe4bb1 100644
--- a/help_to_heat/frontdoor/eligibility.py
+++ b/help_to_heat/frontdoor/eligibility.py
@@ -30,6 +30,7 @@ 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":
@@ -58,6 +59,14 @@ def calculate_eligibility(session_data):
if epc_rating in ("D", "E", "F", "G", "Not found"):
if benefits in ("Yes",):
return ("GBIS", "ECO4")
+
+ # Scenario 2
+ if country in country_council_tax_bands:
+ 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
if country in country_council_tax_bands:
From aeae636f0264f1b7c81ac66fb4b93cbef37f4376 Mon Sep 17 00:00:00 2001
From: Ladun Omideyi
Date: Thu, 4 Jan 2024 14:18:57 +0000
Subject: [PATCH 7/9] PC-NONE: Remove spacing changes
---
help_to_heat/frontdoor/eligibility.py | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/help_to_heat/frontdoor/eligibility.py b/help_to_heat/frontdoor/eligibility.py
index 1dfe4bb1..07d3d7e9 100644
--- a/help_to_heat/frontdoor/eligibility.py
+++ b/help_to_heat/frontdoor/eligibility.py
@@ -46,8 +46,8 @@ def calculate_eligibility(session_data):
# 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",
+ "No, I am a tenant",
+ "Yes, I am the property owner but I lease the property to one or more tenants",
):
if epc_rating in ("E", "F", "G", "Not found"):
if benefits in ("Yes",):
@@ -59,14 +59,6 @@ def calculate_eligibility(session_data):
if epc_rating in ("D", "E", "F", "G", "Not found"):
if benefits in ("Yes",):
return ("GBIS", "ECO4")
-
- # Scenario 2
- if country in country_council_tax_bands:
- 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
if country in country_council_tax_bands:
From 35d8ebd95a08e2f5f8143b2035892769c9d7e405 Mon Sep 17 00:00:00 2001
From: Ladun Omideyi
Date: Thu, 4 Jan 2024 14:26:09 +0000
Subject: [PATCH 8/9] PC-NONE: Remove logging
---
help_to_heat/frontdoor/eligibility.py | 7 -------
1 file changed, 7 deletions(-)
diff --git a/help_to_heat/frontdoor/eligibility.py b/help_to_heat/frontdoor/eligibility.py
index 07d3d7e9..f38c5fcc 100644
--- a/help_to_heat/frontdoor/eligibility.py
+++ b/help_to_heat/frontdoor/eligibility.py
@@ -20,8 +20,6 @@
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
"""
@@ -65,14 +63,12 @@ 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
@@ -80,7 +76,6 @@ 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
@@ -88,7 +83,6 @@ 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
@@ -96,7 +90,6 @@ 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 ()
From 37729dcf9c229d81d6201db0013399a7b79e5fff Mon Sep 17 00:00:00 2001
From: Ladun Omideyi
Date: Thu, 4 Jan 2024 14:59:34 +0000
Subject: [PATCH 9/9] PC-NONE: Alter spacing
---
tests/test_eligibility.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_eligibility.py b/tests/test_eligibility.py
index 9ae4856c..fc165464 100644
--- a/tests/test_eligibility.py
+++ b/tests/test_eligibility.py
@@ -232,6 +232,7 @@ def test_eco4_scenario_2():
expected = result_map["BOTH"]
assert result == expected
+
def test_eco4_scenario_3():
for country in eligible_council_tax:
for own_property in ("No, I am a social housing tenant",):