Skip to content

Commit

Permalink
Merge branch 'PC-605-expanding-possible-scenarios' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiehumphries committed Jan 24, 2024
2 parents 680f3ba + ca409d5 commit 1b8e35f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
11 changes: 6 additions & 5 deletions help_to_heat/frontdoor/eligibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ def _is_eligible_council_tax_band(country, council_tax_band):


def calculate_eligibility(session_data):
epc_rating = session_data.get("epc_rating", "Not found")
council_tax_band = session_data.get("council_tax_band")
country = session_data.get("country")
benefits = session_data.get("benefits")
property_type = session_data.get("property_type")
own_property = session_data.get("own_property")
property_type = session_data.get("property_type")
park_home_main_residence = session_data.get("park_home_main_residence", "No")
council_tax_band = session_data.get("council_tax_band")
epc_rating = session_data.get("epc_rating", "Not found")
accept_suggested_epc = session_data.get("accept_suggested_epc")
benefits = session_data.get("benefits")
household_income = session_data.get("household_income")

if country not in ("England", "Scotland", "Wales"):
return not_eligible

if epc_rating in ("A", "B", "C"):
if epc_rating in ("A", "B", "C") and accept_suggested_epc == "Yes":
return not_eligible

if own_property == "No, I am a social housing tenant":
Expand Down
20 changes: 12 additions & 8 deletions tests/test_eligibility_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@

yes = "Yes"
no = "No"
i_do_not_know = "I do not know"

yes_no = yes, no


def _get_country_options(scenario):
is_england_scotland_or_wales = scenario.get("England, Scotland or Wales?")
if is_england_scotland_or_wales is None:
Expand Down Expand Up @@ -125,14 +125,16 @@ def _get_council_tax_band_options(country, scenario):
return council_tax_bands


def _get_epc_rating_options(scenario):
def _get_epc_rating_and_acceptance_options(scenario):
is_abc = scenario.get("EPC A, B, C?")
is_fg = scenario.get("EPC F or G?")
if is_abc is None:
return epc_ratings
return tuple(itertools.product(epc_ratings, (yes, no, i_do_not_know)))
if is_abc:
return a, b, c
is_fg = scenario.get("EPC F or G?")
return (f, g) if is_fg else (d, e, not_found)
return (a, yes), (b, yes), (c, yes)
if is_fg:
return (f, yes), (g, yes)
return ((d, yes), (e, yes)) + tuple(itertools.product(epc_ratings, (no, i_do_not_know)))


def _get_benefits_options(scenario):
Expand Down Expand Up @@ -175,7 +177,7 @@ def _assert_eligibility(scenario, expected_eligibility):
_get_own_property_options(scenario),
_get_property_type_options(scenario),
_get_park_home_main_residence_options(scenario),
_get_epc_rating_options(scenario),
_get_epc_rating_and_acceptance_options(scenario),
_get_benefits_options(scenario),
_get_household_income_options(scenario),
)
Expand All @@ -184,7 +186,7 @@ def _assert_eligibility(scenario, expected_eligibility):
own_property,
property_type,
park_home_main_residence,
epc_rating,
(epc_rating, accept_suggested_epc),
benefits,
household_income,
) in combinations:
Expand All @@ -197,6 +199,7 @@ def _assert_eligibility(scenario, expected_eligibility):
"park_home_main_residence": park_home_main_residence,
"council_tax_band": council_tax_band,
"epc_rating": epc_rating,
"accept_suggested_epc": accept_suggested_epc,
"benefits": benefits,
"household_income": household_income,
}
Expand All @@ -210,6 +213,7 @@ def _assert_eligibility(scenario, expected_eligibility):
f"Park home main residence: {park_home_main_residence}\n"
f"Council tax band: {council_tax_band}\n"
f"EPC rating: {epc_rating}\n"
f"Accept suggested EPC: {accept_suggested_epc}\n"
f"Benefits: {benefits}\n"
f"Household income: {household_income}\n"
"\n"
Expand Down

0 comments on commit 1b8e35f

Please sign in to comment.