diff --git a/help_to_heat/frontdoor/eligibility.py b/help_to_heat/frontdoor/eligibility.py index f47b37a5..bcb7f89f 100644 --- a/help_to_heat/frontdoor/eligibility.py +++ b/help_to_heat/frontdoor/eligibility.py @@ -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": diff --git a/tests/test_eligibility_scenarios.py b/tests/test_eligibility_scenarios.py index 578b0279..324c91bc 100644 --- a/tests/test_eligibility_scenarios.py +++ b/tests/test_eligibility_scenarios.py @@ -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: @@ -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): @@ -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), ) @@ -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: @@ -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, } @@ -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"