diff --git a/help_to_heat/frontdoor/consts.py b/help_to_heat/frontdoor/consts.py index ab772eb0..b04dc9cd 100644 --- a/help_to_heat/frontdoor/consts.py +++ b/help_to_heat/frontdoor/consts.py @@ -143,28 +143,31 @@ park_home_main_residence_field = "park_home_main_residence" # yes/no options -address_choice_field = "address_choice" -address_choice_field_write_address = "write address" -address_choice_field_epc_api_fail = "epc api fail" -address_choice_field_enter_manually = "enter manually" address_building_name_or_number_field = "building_name_or_number" address_postcode_field = "postcode" # this const was renamed to no longer include lmk. # this is as this field stores info from both flows (lmk & uprn) # the field value is left as is to preserve backwards compatibility address_all_address_and_details_field = "address_and_lmk_details" -address_no_results_field = "no_results" # yes/no options -epc_select_choice_field = "epc_select_choice" -epc_select_choice_field_select_epc = "select epc" -epc_select_choice_field_epc_api_fail = "epc api fail" -epc_select_choice_field_enter_manually = "enter manually" +# journey fields are calculated based on user input & other factors, and decide where the user should go next +# they are stored in the users' session to record the result of these checks, to make journey calculation reproducible +address_choice_journey_field = "address_choice" +address_choice_journey_field_write_address = "write address" +address_choice_journey_field_epc_api_fail = "epc api fail" +address_choice_journey_field_enter_manually = "enter manually" +address_no_results_journey_field = "no_results" # yes/no options -address_select_choice_field = "address_select_choice" -address_select_choice_field_select_address = "select address" -address_select_choice_field_enter_manually = "enter manually" +epc_select_choice_journey_field = "epc_select_choice" +epc_select_choice_journey_field_select_epc = "select epc" +epc_select_choice_journey_field_epc_api_fail = "epc api fail" +epc_select_choice_journey_field_enter_manually = "enter manually" -referral_already_submitted_field = "submit_another" +address_select_choice_journey_field = "address_select_choice" +address_select_choice_journey_field_select_address = "select address" +address_select_choice_journey_field_enter_manually = "enter manually" + +referral_already_submitted_journey_field = "submit_another" address_manual_address_line_1_field = "address_line_1" address_manual_address_line_2_field = "address_line_2" @@ -172,8 +175,8 @@ address_manual_county_field = "county" address_manual_postcode_field = "postcode" -duplicate_uprn_field = "uprn_is_duplicate" -epc_found_field = "epc_found" +duplicate_uprn_journey_field = "uprn_is_duplicate" +epc_found_journey_field = "epc_found" lmk_field = "lmk" lmk_field_enter_manually = "enter-manually" address_field = "address" diff --git a/help_to_heat/frontdoor/routing/forwards_routing.py b/help_to_heat/frontdoor/routing/forwards_routing.py index d4cc0446..941c3d4e 100644 --- a/help_to_heat/frontdoor/routing/forwards_routing.py +++ b/help_to_heat/frontdoor/routing/forwards_routing.py @@ -1,13 +1,13 @@ from help_to_heat.frontdoor.consts import ( - address_choice_field, - address_choice_field_enter_manually, - address_choice_field_epc_api_fail, - address_choice_field_write_address, + address_choice_journey_field, + address_choice_journey_field_enter_manually, + address_choice_journey_field_epc_api_fail, + address_choice_journey_field_write_address, address_manual_page, - address_no_results_field, + address_no_results_journey_field, address_page, - address_select_choice_field, - address_select_choice_field_select_address, + address_select_choice_journey_field, + address_select_choice_journey_field_select_address, address_select_manual_page, address_select_page, benefits_field, @@ -24,16 +24,16 @@ country_field_scotland, country_field_wales, country_page, - duplicate_uprn_field, + duplicate_uprn_journey_field, epc_accept_suggested_epc_field, - epc_found_field, + epc_found_journey_field, epc_ineligible_page, epc_page, epc_rating_is_eligible_field, - epc_select_choice_field, - epc_select_choice_field_enter_manually, - epc_select_choice_field_epc_api_fail, - epc_select_choice_field_select_epc, + epc_select_choice_journey_field, + epc_select_choice_journey_field_enter_manually, + epc_select_choice_journey_field_epc_api_fail, + epc_select_choice_journey_field_select_epc, epc_select_manual_page, epc_select_page, field_no, @@ -320,48 +320,48 @@ def _park_home_main_residence_next_page(answers): return _unknown_response -@_requires_answer(address_choice_field) +@_requires_answer(address_choice_journey_field) def _address_next_page(answers): - address_choice = answers.get(address_choice_field) - address_no_results = answers.get(address_no_results_field) + address_choice = answers.get(address_choice_journey_field) + address_no_results = answers.get(address_no_results_journey_field) country = answers.get(country_field) if address_no_results == field_yes: return address_manual_page - if address_choice == address_choice_field_write_address: + if address_choice == address_choice_journey_field_write_address: if country in [country_field_england, country_field_wales]: return epc_select_page if country == country_field_scotland: return address_select_page - if address_choice == address_choice_field_epc_api_fail: + if address_choice == address_choice_journey_field_epc_api_fail: return address_select_page - if address_choice == address_choice_field_enter_manually: + if address_choice == address_choice_journey_field_enter_manually: return address_manual_page return _unknown_response -@_requires_answer(epc_select_choice_field) +@_requires_answer(epc_select_choice_journey_field) def _epc_select_next_page(answers): - choice = answers.get(epc_select_choice_field) + choice = answers.get(epc_select_choice_journey_field) - if choice == epc_select_choice_field_select_epc: + if choice == epc_select_choice_journey_field_select_epc: return _post_address_input_next_page(answers) - if choice == epc_select_choice_field_epc_api_fail: + if choice == epc_select_choice_journey_field_epc_api_fail: return address_select_page - if choice == epc_select_choice_field_enter_manually: + if choice == epc_select_choice_journey_field_enter_manually: return epc_select_manual_page return _unknown_response -@_requires_answer(address_select_choice_field) +@_requires_answer(address_select_choice_journey_field) def _address_select_next_page(answers): - choice = answers.get(address_select_choice_field) + choice = answers.get(address_select_choice_journey_field) - if choice == address_select_choice_field_select_address: + if choice == address_select_choice_journey_field_select_address: return _post_address_input_next_page(answers) - if choice == address_choice_field_enter_manually: + if choice == address_choice_journey_field_enter_manually: return address_select_manual_page return _unknown_response @@ -381,7 +381,7 @@ def _address_select_manual_next_page(answers): # after submitting an address, show already submitted page or continue def _post_address_input_next_page(answers): - duplicate_uprn = answers.get(duplicate_uprn_field) + duplicate_uprn = answers.get(duplicate_uprn_journey_field) if duplicate_uprn == field_yes: return referral_already_submitted_page if duplicate_uprn == field_no: @@ -416,19 +416,19 @@ def _council_tax_band_next_page(answers): # confirms epc if it was found, or send to no epc def _post_council_tax_band_next_page(answers): - epc_found = answers.get(epc_found_field) - address_choice = answers.get(address_choice_field) - epc_select_choice = answers.get(epc_select_choice_field) - address_select_choice = answers.get(address_select_choice_field) + epc_found = answers.get(epc_found_journey_field) + address_choice = answers.get(address_choice_journey_field) + epc_select_choice = answers.get(epc_select_choice_journey_field) + address_select_choice = answers.get(address_select_choice_journey_field) if epc_found == field_yes: return epc_page if epc_found == field_no: # if they entered an address manually, don't show the no epc page as an epc wasn't searched for # note that there are 3 address select pages so 3 places where the user can opt to enter manually if ( - address_choice == address_choice_field_enter_manually - or epc_select_choice == epc_select_choice_field_enter_manually - or address_select_choice == address_choice_field_enter_manually + address_choice == address_choice_journey_field_enter_manually + or epc_select_choice == epc_select_choice_journey_field_enter_manually + or address_select_choice == address_choice_journey_field_enter_manually ): return _post_epc_next_page(answers) diff --git a/help_to_heat/frontdoor/views.py b/help_to_heat/frontdoor/views.py index 587d8ee2..0ac98e49 100644 --- a/help_to_heat/frontdoor/views.py +++ b/help_to_heat/frontdoor/views.py @@ -18,10 +18,10 @@ from .consts import ( address_all_address_and_details_field, address_building_name_or_number_field, - address_choice_field, - address_choice_field_enter_manually, - address_choice_field_epc_api_fail, - address_choice_field_write_address, + address_choice_journey_field, + address_choice_journey_field_enter_manually, + address_choice_journey_field_epc_api_fail, + address_choice_journey_field_write_address, address_field, address_manual_address_line_1_field, address_manual_address_line_2_field, @@ -29,12 +29,12 @@ address_manual_page, address_manual_postcode_field, address_manual_town_or_city_field, - address_no_results_field, + address_no_results_journey_field, address_page, address_postcode_field, - address_select_choice_field, - address_select_choice_field_enter_manually, - address_select_choice_field_select_address, + address_select_choice_journey_field, + address_select_choice_journey_field_enter_manually, + address_select_choice_journey_field_select_address, address_select_manual_page, address_select_page, all_pages, @@ -57,20 +57,20 @@ country_field_scotland, country_field_wales, country_page, - duplicate_uprn_field, + duplicate_uprn_journey_field, epc_accept_suggested_epc_field, epc_accept_suggested_epc_field_not_found, epc_details_field, - epc_found_field, + epc_found_journey_field, epc_ineligible_page, epc_page, epc_rating_field, epc_rating_field_not_found, epc_rating_is_eligible_field, - epc_select_choice_field, - epc_select_choice_field_enter_manually, - epc_select_choice_field_epc_api_fail, - epc_select_choice_field_select_epc, + epc_select_choice_journey_field, + epc_select_choice_journey_field_enter_manually, + epc_select_choice_journey_field_epc_api_fail, + epc_select_choice_journey_field_select_epc, epc_select_manual_page, epc_select_page, field_no, @@ -113,7 +113,7 @@ property_type_field, property_type_page, recommendations_field, - referral_already_submitted_field, + referral_already_submitted_journey_field, referral_already_submitted_page, schemes_contribution_acknowledgement_field, schemes_field, @@ -181,7 +181,7 @@ address_manual_town_or_city_field, address_manual_postcode_field, ), - referral_already_submitted_page: (referral_already_submitted_field,), + referral_already_submitted_page: (referral_already_submitted_journey_field,), council_tax_band_page: (council_tax_band_field,), epc_page: (epc_accept_suggested_epc_field,), benefits_page: (benefits_field,), @@ -210,7 +210,7 @@ uprn_field: _("Select your address, or I can't find my address if your address is not listed"), lmk_field: _("Select your address, or I can't find my address if your address is not listed"), address_manual_town_or_city_field: _("Enter your Town or city"), - referral_already_submitted_field: _("Please confirm that you want to submit another referral"), + referral_already_submitted_journey_field: _("Please confirm that you want to submit another referral"), council_tax_band_field: _("Enter the Council Tax Band of the property"), epc_accept_suggested_epc_field: _("Select if your EPC rating is correct or not, or that you do not know"), benefits_field: _("Select if anyone in your household is receiving any benefits listed below"), @@ -619,7 +619,7 @@ def build_extra_context(self, request, session_id, page_name, data, is_change_pa def save_get_data(self, data, session_id, page_name): # this ensures that if the user presses enter manually they will not see the no results error - data[address_no_results_field] = field_no + data[address_no_results_journey_field] = field_no return data def save_post_data(self, data, session_id, page_name): @@ -637,7 +637,7 @@ def save_post_data(self, data, session_id, page_name): data[address_all_address_and_details_field] = address_details - data[address_no_results_field] = field_yes if len(address_details) == 0 else field_no + data[address_no_results_journey_field] = field_yes if len(address_details) == 0 else field_no return data @@ -647,15 +647,15 @@ def _select_api_and_request(self, building_name_or_number, postcode, country, da address_and_lmk_details = interface.api.epc.get_address_and_epc_lmk(building_name_or_number, postcode) if len(address_and_lmk_details) > 0: most_recent_address_and_lmk_details = utils.get_most_recent_epc_per_uprn(address_and_lmk_details) - data[address_choice_field] = address_choice_field_write_address + data[address_choice_journey_field] = address_choice_journey_field_write_address return most_recent_address_and_lmk_details, data else: - data[address_choice_field] = address_choice_field_epc_api_fail + data[address_choice_journey_field] = address_choice_journey_field_epc_api_fail else: - data[address_choice_field] = address_choice_field_write_address + data[address_choice_journey_field] = address_choice_journey_field_write_address except Exception as e: # noqa: B902 logger.exception(f"An error occurred: {e}") - data[address_choice_field] = address_choice_field_epc_api_fail + data[address_choice_journey_field] = address_choice_journey_field_epc_api_fail # if didn't return epc api data, return os api data return interface.api.address.find_addresses(building_name_or_number, postcode), data @@ -701,7 +701,7 @@ def save_post_data(self, data, session_id, page_name): lmk = data.get(lmk_field) if lmk == lmk_field_enter_manually: - data[epc_select_choice_field] = epc_select_choice_field_enter_manually + data[epc_select_choice_journey_field] = epc_select_choice_journey_field_enter_manually return data try: @@ -709,10 +709,10 @@ def save_post_data(self, data, session_id, page_name): except Exception as e: # noqa: B902 logger.exception(f"An error occurred: {e}") reset_epc_details(session_id) - data[epc_select_choice_field] = epc_select_choice_field_epc_api_fail + data[epc_select_choice_journey_field] = epc_select_choice_journey_field_epc_api_fail return data - data[epc_select_choice_field] = epc_select_choice_field_select_epc + data[epc_select_choice_journey_field] = epc_select_choice_journey_field_select_epc uprn = epc_details.get("uprn") address = epc_details.get("address") @@ -728,10 +728,10 @@ def save_post_data(self, data, session_id, page_name): data = {**data, **epc_data} duplicate_referral_checker = DuplicateReferralChecker(session_id, data) - data[duplicate_uprn_field] = ( + data[duplicate_uprn_journey_field] = ( field_yes if duplicate_referral_checker.is_referral_a_recent_duplicate() else field_no ) - data[epc_found_field] = field_yes + data[epc_found_journey_field] = field_yes return data @@ -778,29 +778,29 @@ def save_post_data(self, data, session_id, page_name): uprn = data.get(uprn_field) if uprn == uprn_field_enter_manually: - data[address_select_choice_field] = address_select_choice_field_enter_manually + data[address_select_choice_journey_field] = address_select_choice_journey_field_enter_manually return data - data[address_select_choice_field] = address_select_choice_field_select_address + data[address_select_choice_journey_field] = address_select_choice_journey_field_select_address address_data = interface.api.address.get_address(uprn) data[address_field] = address_data["address"] duplicate_referral_checker = DuplicateReferralChecker(session_id) - data[duplicate_uprn_field] = ( + data[duplicate_uprn_journey_field] = ( field_yes if duplicate_referral_checker.is_referral_a_recent_duplicate() else field_no ) answers = interface.api.session.get_session(session_id) country = answers.get(country_field) - data[epc_found_field] = field_no + data[epc_found_journey_field] = field_no if country == country_field_scotland and uprn is not None: epc = interface.api.epc.get_epc_scotland(uprn) if epc != {}: data[epc_details_field] = epc - data[epc_found_field] = field_yes + data[epc_found_journey_field] = field_yes return data @@ -835,7 +835,7 @@ def build_extra_context(self, request, session_id, page_name, data, is_change_pa session_data = interface.api.session.get_session(session_id) # validation errors get priority, don't show both at once - show_address_manually_error = session_data[address_no_results_field] == field_yes and len(errors) == 0 + show_address_manually_error = session_data[address_no_results_journey_field] == field_yes and len(errors) == 0 context_data = { **answer_data, @@ -858,15 +858,15 @@ def save_post_data(self, data, session_id, page_name): ) address = ", ".join(f for f in fields if f) data[address_field] = address - data[duplicate_uprn_field] = field_no - data[epc_found_field] = field_no + data[duplicate_uprn_journey_field] = field_no + data[epc_found_journey_field] = field_no if page_name == address_manual_page: - data[address_choice_field] = address_choice_field_enter_manually + data[address_choice_journey_field] = address_choice_journey_field_enter_manually if page_name == epc_select_manual_page: - data[epc_select_choice_field] = epc_select_choice_field_enter_manually + data[epc_select_choice_journey_field] = epc_select_choice_journey_field_enter_manually if page_name == address_select_manual_page: - data[address_select_choice_field] = address_select_choice_field_enter_manually + data[address_select_choice_journey_field] = address_select_choice_journey_field_enter_manually return data diff --git a/tests/routing/__init__.py b/tests/routing/__init__.py index f67cdd19..7edcd43a 100644 --- a/tests/routing/__init__.py +++ b/tests/routing/__init__.py @@ -1,12 +1,12 @@ from help_to_heat.frontdoor.consts import ( - address_choice_field, - address_choice_field_enter_manually, - address_choice_field_epc_api_fail, - address_choice_field_write_address, - address_no_results_field, - address_select_choice_field, - address_select_choice_field_enter_manually, - address_select_choice_field_select_address, + address_choice_journey_field, + address_choice_journey_field_enter_manually, + address_choice_journey_field_epc_api_fail, + address_choice_journey_field_write_address, + address_no_results_journey_field, + address_select_choice_journey_field, + address_select_choice_journey_field_enter_manually, + address_select_choice_journey_field_select_address, benefits_field, bulb_warning_page_field, council_tax_band_field, @@ -24,14 +24,14 @@ country_field_england, country_field_scotland, country_field_wales, - duplicate_uprn_field, + duplicate_uprn_journey_field, epc_accept_suggested_epc_field, - epc_found_field, + epc_found_journey_field, epc_rating_is_eligible_field, - epc_select_choice_field, - epc_select_choice_field_enter_manually, - epc_select_choice_field_epc_api_fail, - epc_select_choice_field_select_epc, + epc_select_choice_journey_field, + epc_select_choice_journey_field_enter_manually, + epc_select_choice_journey_field_epc_api_fail, + epc_select_choice_journey_field_select_epc, field_dont_know, field_no, field_yes, @@ -265,83 +265,90 @@ def _get_address_input_answers_pre_duplicate_uprn(address_flow, property_flow=No if address_flow == address_flow_write_address_epc_hit_select: yield { **flow_answers, - address_choice_field: address_choice_field_write_address, - epc_select_choice_field: epc_select_choice_field_select_epc, - epc_found_field: field_yes, + address_choice_journey_field: address_choice_journey_field_write_address, + epc_select_choice_journey_field: epc_select_choice_journey_field_select_epc, + epc_found_journey_field: field_yes, } if address_flow == address_flow_write_address_epc_hit_write_manually: yield { **flow_answers, - address_choice_field: address_choice_field_write_address, - epc_select_choice_field: epc_select_choice_field_enter_manually, - epc_found_field: field_no, + address_choice_journey_field: address_choice_journey_field_write_address, + epc_select_choice_journey_field: epc_select_choice_journey_field_enter_manually, + epc_found_journey_field: field_no, } if address_flow == address_flow_write_address_epc_api_fail_select: yield { **flow_answers, - address_choice_field: address_choice_field_epc_api_fail, - address_select_choice_field: address_select_choice_field_select_address, - epc_found_field: field_no, + address_choice_journey_field: address_choice_journey_field_epc_api_fail, + address_select_choice_journey_field: address_select_choice_journey_field_select_address, + epc_found_journey_field: field_no, } yield { **flow_answers, - address_choice_field: address_choice_field_write_address, - epc_select_choice_field: epc_select_choice_field_epc_api_fail, - address_select_choice_field: address_select_choice_field_select_address, - epc_found_field: field_no, + address_choice_journey_field: address_choice_journey_field_write_address, + epc_select_choice_journey_field: epc_select_choice_journey_field_epc_api_fail, + address_select_choice_journey_field: address_select_choice_journey_field_select_address, + epc_found_journey_field: field_no, } if address_flow == address_flow_write_address_epc_api_fail_manually: yield { **flow_answers, - address_choice_field: address_choice_field_epc_api_fail, - address_select_choice_field: address_select_choice_field_enter_manually, - epc_found_field: field_no, + address_choice_journey_field: address_choice_journey_field_epc_api_fail, + address_select_choice_journey_field: address_select_choice_journey_field_enter_manually, + epc_found_journey_field: field_no, } yield { **flow_answers, - address_choice_field: address_choice_field_write_address, - epc_select_choice_field: epc_select_choice_field_epc_api_fail, - address_select_choice_field: address_select_choice_field_enter_manually, - epc_found_field: field_no, + address_choice_journey_field: address_choice_journey_field_write_address, + epc_select_choice_journey_field: epc_select_choice_journey_field_epc_api_fail, + address_select_choice_journey_field: address_select_choice_journey_field_enter_manually, + epc_found_journey_field: field_no, } if address_flow == address_flow_write_address_scotland_select_epc: yield { **flow_answers, - address_choice_field: address_choice_field_write_address, - address_select_choice_field: address_select_choice_field_select_address, - epc_found_field: field_yes, + address_choice_journey_field: address_choice_journey_field_write_address, + address_select_choice_journey_field: address_select_choice_journey_field_select_address, + epc_found_journey_field: field_yes, } if address_flow == address_flow_write_address_scotland_select_no_epc: yield { **flow_answers, - address_choice_field: address_choice_field_write_address, - address_select_choice_field: address_select_choice_field_select_address, - epc_found_field: field_no, + address_choice_journey_field: address_choice_journey_field_write_address, + address_select_choice_journey_field: address_select_choice_journey_field_select_address, + epc_found_journey_field: field_no, } if address_flow == address_flow_write_address_scotland_manually: yield { **flow_answers, - address_choice_field: address_choice_field_write_address, - address_select_choice_field: address_select_choice_field_enter_manually, - epc_found_field: field_no, + address_choice_journey_field: address_choice_journey_field_write_address, + address_select_choice_journey_field: address_select_choice_journey_field_enter_manually, + epc_found_journey_field: field_no, } if address_flow == address_flow_manually: - yield {**flow_answers, address_choice_field: address_choice_field_enter_manually, epc_found_field: field_no} + yield { + **flow_answers, + address_choice_journey_field: address_choice_journey_field_enter_manually, + epc_found_journey_field: field_no, + } if address_flow == address_flow_no_results: - for address_choice in [address_choice_field_write_address, address_choice_field_epc_api_fail]: + for address_choice in [ + address_choice_journey_field_write_address, + address_choice_journey_field_epc_api_fail, + ]: yield { **flow_answers, - address_choice_field: address_choice, - address_no_results_field: field_yes, - epc_found_field: field_no, + address_choice_journey_field: address_choice, + address_no_results_journey_field: field_yes, + epc_found_journey_field: field_no, } @@ -349,7 +356,7 @@ def _get_address_input_answers_pre_duplicate_uprn(address_flow, property_flow=No def get_address_answers(address_flow, duplicate_uprn=None, property_flow=None): for address_answers in _get_address_input_answers_pre_duplicate_uprn(address_flow, property_flow): if duplicate_uprn is not None: - yield {**address_answers, duplicate_uprn_field: duplicate_uprn} + yield {**address_answers, duplicate_uprn_journey_field: duplicate_uprn} else: # if flow is one where a UPRN is checked, add options for whether a UPRN hit happened if address_flow in [ @@ -358,8 +365,8 @@ def get_address_answers(address_flow, duplicate_uprn=None, property_flow=None): address_flow_write_address_scotland_select_epc, address_flow_write_address_scotland_select_no_epc, ]: - yield {**address_answers, duplicate_uprn_field: field_yes} - yield {**address_answers, duplicate_uprn_field: field_no} + yield {**address_answers, duplicate_uprn_journey_field: field_yes} + yield {**address_answers, duplicate_uprn_journey_field: field_no} else: yield address_answers diff --git a/tests/routing/test_backwards_routing.py b/tests/routing/test_backwards_routing.py index 29103c8c..c1fd16a9 100644 --- a/tests/routing/test_backwards_routing.py +++ b/tests/routing/test_backwards_routing.py @@ -1,15 +1,15 @@ import pytest from help_to_heat.frontdoor.consts import ( - address_choice_field, - address_choice_field_enter_manually, - address_choice_field_epc_api_fail, - address_choice_field_write_address, + address_choice_journey_field, + address_choice_journey_field_enter_manually, + address_choice_journey_field_epc_api_fail, + address_choice_journey_field_write_address, address_manual_page, - address_no_results_field, + address_no_results_journey_field, address_page, - address_select_choice_field, - address_select_choice_field_enter_manually, + address_select_choice_journey_field, + address_select_choice_journey_field_enter_manually, address_select_manual_page, address_select_page, benefits_field, @@ -26,14 +26,14 @@ country_field_scotland, country_field_wales, country_page, - duplicate_uprn_field, + duplicate_uprn_journey_field, epc_accept_suggested_epc_field, epc_ineligible_page, epc_page, epc_rating_is_eligible_field, - epc_select_choice_field, - epc_select_choice_field_enter_manually, - epc_select_choice_field_epc_api_fail, + epc_select_choice_journey_field, + epc_select_choice_journey_field_enter_manually, + epc_select_choice_journey_field_epc_api_fail, epc_select_manual_page, epc_select_page, field_no, @@ -224,7 +224,7 @@ def test_epc_select_prev_page(): for flow_answers in get_property_flow_answers(): country = flow_answers.get(country_field) if country != country_field_scotland: - answers = {**flow_answers, address_choice_field: address_choice_field_write_address} + answers = {**flow_answers, address_choice_journey_field: address_choice_journey_field_write_address} assert get_prev_page(epc_select_page, answers) == address_page @@ -232,17 +232,17 @@ def test_address_select_prev_page(): for flow_answers in get_property_flow_answers(): country = flow_answers[country_field] if country in [country_field_england, country_field_wales]: - answers = {**flow_answers, address_choice_field: address_choice_field_epc_api_fail} + answers = {**flow_answers, address_choice_journey_field: address_choice_journey_field_epc_api_fail} assert get_prev_page(address_select_page, answers) == address_page answers = { **flow_answers, - address_choice_field: address_choice_field_write_address, - epc_select_choice_field: epc_select_choice_field_epc_api_fail, + address_choice_journey_field: address_choice_journey_field_write_address, + epc_select_choice_journey_field: epc_select_choice_journey_field_epc_api_fail, } assert get_prev_page(address_select_page, answers) == epc_select_page if country == country_field_scotland: - answers = {**flow_answers, address_choice_field: address_choice_field_write_address} + answers = {**flow_answers, address_choice_journey_field: address_choice_journey_field_write_address} assert get_prev_page(address_select_page, answers) == address_page @@ -250,13 +250,17 @@ def test_address_manual_from_address_page_prev_page(): for flow_answers in get_property_flow_answers(): answers = { **flow_answers, - address_choice_field: address_choice_field_enter_manually, + address_choice_journey_field: address_choice_journey_field_enter_manually, } assert get_prev_page(address_manual_page, answers) == address_page - for address_choice in [address_choice_field_write_address, address_choice_field_epc_api_fail]: - answers = {**flow_answers, address_choice_field: address_choice, address_no_results_field: field_yes} + for address_choice in [address_choice_journey_field_write_address, address_choice_journey_field_epc_api_fail]: + answers = { + **flow_answers, + address_choice_journey_field: address_choice, + address_no_results_journey_field: field_yes, + } assert get_prev_page(address_manual_page, answers) == address_page @@ -266,8 +270,8 @@ def test_epc_select_manual_from_epc_select_page_prev_page(): if country in [country_field_england, country_field_wales]: answers = { **flow_answers, - address_choice_field: address_choice_field_write_address, - epc_select_choice_field: epc_select_choice_field_enter_manually, + address_choice_journey_field: address_choice_journey_field_write_address, + epc_select_choice_journey_field: epc_select_choice_journey_field_enter_manually, } assert get_prev_page(epc_select_manual_page, answers) == epc_select_page @@ -278,17 +282,17 @@ def test_address_select_manual_from_address_select_page_prev_page(): if country in [country_field_england, country_field_wales]: answers = { **flow_answers, - address_choice_field: address_choice_field_write_address, - epc_select_choice_field: epc_select_choice_field_epc_api_fail, - address_select_choice_field: address_select_choice_field_enter_manually, + address_choice_journey_field: address_choice_journey_field_write_address, + epc_select_choice_journey_field: epc_select_choice_journey_field_epc_api_fail, + address_select_choice_journey_field: address_select_choice_journey_field_enter_manually, } assert get_prev_page(address_select_manual_page, answers) == address_select_page if country == country_field_scotland: answers = { **flow_answers, - address_choice_field: address_choice_field_write_address, - address_select_choice_field: address_select_choice_field_enter_manually, + address_choice_journey_field: address_choice_journey_field_write_address, + address_select_choice_journey_field: address_select_choice_journey_field_enter_manually, } assert get_prev_page(address_select_manual_page, answers) == address_select_page @@ -304,7 +308,7 @@ def test_address_select_manual_from_address_select_page_prev_page(): ) def test_referral_already_submitted_page_prev_page(address_flow, expected_prev_page): for flow_answers in get_address_answers(address_flow): - answers = {**flow_answers, duplicate_uprn_field: field_yes} + answers = {**flow_answers, duplicate_uprn_journey_field: field_yes} assert get_prev_page(referral_already_submitted_page, answers) == expected_prev_page diff --git a/tests/routing/test_forwards_routing.py b/tests/routing/test_forwards_routing.py index a74c67f1..f7207ecf 100644 --- a/tests/routing/test_forwards_routing.py +++ b/tests/routing/test_forwards_routing.py @@ -1,16 +1,16 @@ import pytest from help_to_heat.frontdoor.consts import ( - address_choice_field, - address_choice_field_enter_manually, - address_choice_field_epc_api_fail, - address_choice_field_write_address, + address_choice_journey_field, + address_choice_journey_field_enter_manually, + address_choice_journey_field_epc_api_fail, + address_choice_journey_field_write_address, address_manual_page, - address_no_results_field, + address_no_results_journey_field, address_page, - address_select_choice_field, - address_select_choice_field_enter_manually, - address_select_choice_field_select_address, + address_select_choice_journey_field, + address_select_choice_journey_field_enter_manually, + address_select_choice_journey_field_select_address, address_select_manual_page, address_select_page, benefits_field, @@ -28,16 +28,16 @@ country_field_scotland, country_field_wales, country_page, - duplicate_uprn_field, + duplicate_uprn_journey_field, epc_accept_suggested_epc_field, - epc_found_field, + epc_found_journey_field, epc_ineligible_page, epc_page, epc_rating_is_eligible_field, - epc_select_choice_field, - epc_select_choice_field_enter_manually, - epc_select_choice_field_epc_api_fail, - epc_select_choice_field_select_epc, + epc_select_choice_journey_field, + epc_select_choice_journey_field_enter_manually, + epc_select_choice_journey_field_epc_api_fail, + epc_select_choice_journey_field_select_epc, epc_select_manual_page, epc_select_page, field_dont_know, @@ -250,9 +250,9 @@ def test_park_home_main_residence_next_page(park_home_main_residence, expected_n ) def test_address_write_address_next_page(country, no_results, expected_next_page): answers = { - address_choice_field: address_choice_field_write_address, + address_choice_journey_field: address_choice_journey_field_write_address, country_field: country, - address_no_results_field: no_results, + address_no_results_journey_field: no_results, } assert get_next_page(address_page, answers) == expected_next_page @@ -265,35 +265,38 @@ def test_address_write_address_next_page(country, no_results, expected_next_page ], ) def test_address_epc_api_fail_next_page(no_results, expected_next_page): - answers = {address_choice_field: address_choice_field_epc_api_fail, address_no_results_field: no_results} + answers = { + address_choice_journey_field: address_choice_journey_field_epc_api_fail, + address_no_results_journey_field: no_results, + } assert get_next_page(address_page, answers) == expected_next_page def test_address_enter_manually_next_page(): - answers = {address_choice_field: address_choice_field_enter_manually} + answers = {address_choice_journey_field: address_choice_journey_field_enter_manually} assert get_next_page(address_page, answers) == address_manual_page @pytest.mark.parametrize( "choice, duplicate_uprn, expected_next_page", [ - (epc_select_choice_field_select_epc, field_no, epc_page), - (epc_select_choice_field_select_epc, field_yes, referral_already_submitted_page), - (epc_select_choice_field_epc_api_fail, field_no, address_select_page), - (epc_select_choice_field_epc_api_fail, field_yes, address_select_page), - (epc_select_choice_field_enter_manually, field_no, epc_select_manual_page), - (epc_select_choice_field_enter_manually, field_yes, epc_select_manual_page), + (epc_select_choice_journey_field_select_epc, field_no, epc_page), + (epc_select_choice_journey_field_select_epc, field_yes, referral_already_submitted_page), + (epc_select_choice_journey_field_epc_api_fail, field_no, address_select_page), + (epc_select_choice_journey_field_epc_api_fail, field_yes, address_select_page), + (epc_select_choice_journey_field_enter_manually, field_no, epc_select_manual_page), + (epc_select_choice_journey_field_enter_manually, field_yes, epc_select_manual_page), ], ) def test_epc_select_park_home_next_page(choice, duplicate_uprn, expected_next_page): - epc_found = field_yes if choice == epc_select_choice_field_select_epc else field_no + epc_found = field_yes if choice == epc_select_choice_journey_field_select_epc else field_no for own_property in own_property_fields_non_social_housing: answers = { - epc_select_choice_field: choice, - duplicate_uprn_field: duplicate_uprn, + epc_select_choice_journey_field: choice, + duplicate_uprn_journey_field: duplicate_uprn, own_property_field: own_property, park_home_field: field_yes, - epc_found_field: epc_found, + epc_found_journey_field: epc_found, } assert get_next_page(epc_select_page, answers) == expected_next_page @@ -301,19 +304,19 @@ def test_epc_select_park_home_next_page(choice, duplicate_uprn, expected_next_pa @pytest.mark.parametrize( "choice, duplicate_uprn, expected_next_page", [ - (epc_select_choice_field_select_epc, field_no, council_tax_band_page), - (epc_select_choice_field_select_epc, field_yes, referral_already_submitted_page), - (epc_select_choice_field_epc_api_fail, field_no, address_select_page), - (epc_select_choice_field_epc_api_fail, field_yes, address_select_page), - (epc_select_choice_field_enter_manually, field_no, epc_select_manual_page), - (epc_select_choice_field_enter_manually, field_yes, epc_select_manual_page), + (epc_select_choice_journey_field_select_epc, field_no, council_tax_band_page), + (epc_select_choice_journey_field_select_epc, field_yes, referral_already_submitted_page), + (epc_select_choice_journey_field_epc_api_fail, field_no, address_select_page), + (epc_select_choice_journey_field_epc_api_fail, field_yes, address_select_page), + (epc_select_choice_journey_field_enter_manually, field_no, epc_select_manual_page), + (epc_select_choice_journey_field_enter_manually, field_yes, epc_select_manual_page), ], ) def test_epc_select_not_park_home_not_already_submitted_next_page(choice, duplicate_uprn, expected_next_page): for own_property in own_property_fields_non_social_housing: answers = { - epc_select_choice_field: choice, - duplicate_uprn_field: duplicate_uprn, + epc_select_choice_journey_field: choice, + duplicate_uprn_journey_field: duplicate_uprn, own_property_field: own_property, park_home_field: field_no, } @@ -323,21 +326,21 @@ def test_epc_select_not_park_home_not_already_submitted_next_page(choice, duplic @pytest.mark.parametrize( "choice, duplicate_uprn, expected_next_page", [ - (epc_select_choice_field_select_epc, field_no, epc_page), - (epc_select_choice_field_select_epc, field_yes, referral_already_submitted_page), - (epc_select_choice_field_epc_api_fail, field_no, address_select_page), - (epc_select_choice_field_epc_api_fail, field_yes, address_select_page), - (epc_select_choice_field_enter_manually, field_no, epc_select_manual_page), - (epc_select_choice_field_enter_manually, field_yes, epc_select_manual_page), + (epc_select_choice_journey_field_select_epc, field_no, epc_page), + (epc_select_choice_journey_field_select_epc, field_yes, referral_already_submitted_page), + (epc_select_choice_journey_field_epc_api_fail, field_no, address_select_page), + (epc_select_choice_journey_field_epc_api_fail, field_yes, address_select_page), + (epc_select_choice_journey_field_enter_manually, field_no, epc_select_manual_page), + (epc_select_choice_journey_field_enter_manually, field_yes, epc_select_manual_page), ], ) def test_epc_select_social_housing_next_page(choice, duplicate_uprn, expected_next_page): - epc_found = field_yes if choice == epc_select_choice_field_select_epc else field_no + epc_found = field_yes if choice == epc_select_choice_journey_field_select_epc else field_no answers = { - epc_select_choice_field: choice, - duplicate_uprn_field: duplicate_uprn, + epc_select_choice_journey_field: choice, + duplicate_uprn_journey_field: duplicate_uprn, own_property_field: own_property_field_social_housing, - epc_found_field: epc_found, + epc_found_journey_field: epc_found, } assert get_next_page(epc_select_page, answers) == expected_next_page @@ -345,24 +348,24 @@ def test_epc_select_social_housing_next_page(choice, duplicate_uprn, expected_ne @pytest.mark.parametrize( "choice, duplicate_uprn, epc_found, expected_next_page", [ - (address_select_choice_field_select_address, field_no, field_no, no_epc_page), - (address_select_choice_field_select_address, field_no, field_yes, epc_page), - (address_select_choice_field_select_address, field_yes, field_no, referral_already_submitted_page), - (address_select_choice_field_select_address, field_yes, field_yes, referral_already_submitted_page), - (address_select_choice_field_enter_manually, field_no, field_no, address_select_manual_page), - (address_select_choice_field_enter_manually, field_no, field_yes, address_select_manual_page), - (address_select_choice_field_enter_manually, field_yes, field_no, address_select_manual_page), - (address_select_choice_field_enter_manually, field_yes, field_yes, address_select_manual_page), + (address_select_choice_journey_field_select_address, field_no, field_no, no_epc_page), + (address_select_choice_journey_field_select_address, field_no, field_yes, epc_page), + (address_select_choice_journey_field_select_address, field_yes, field_no, referral_already_submitted_page), + (address_select_choice_journey_field_select_address, field_yes, field_yes, referral_already_submitted_page), + (address_select_choice_journey_field_enter_manually, field_no, field_no, address_select_manual_page), + (address_select_choice_journey_field_enter_manually, field_no, field_yes, address_select_manual_page), + (address_select_choice_journey_field_enter_manually, field_yes, field_no, address_select_manual_page), + (address_select_choice_journey_field_enter_manually, field_yes, field_yes, address_select_manual_page), ], ) def test_address_select_park_home_next_page(choice, duplicate_uprn, epc_found, expected_next_page): for own_property in own_property_fields_non_social_housing: answers = { - address_select_choice_field: choice, + address_select_choice_journey_field: choice, own_property_field: own_property, park_home_field: field_yes, - epc_found_field: epc_found, - duplicate_uprn_field: duplicate_uprn, + epc_found_journey_field: epc_found, + duplicate_uprn_journey_field: duplicate_uprn, } assert get_next_page(address_select_page, answers) == expected_next_page @@ -370,24 +373,24 @@ def test_address_select_park_home_next_page(choice, duplicate_uprn, epc_found, e @pytest.mark.parametrize( "choice, duplicate_uprn, epc_found, expected_next_page", [ - (address_select_choice_field_select_address, field_no, field_no, council_tax_band_page), - (address_select_choice_field_select_address, field_no, field_yes, council_tax_band_page), - (address_select_choice_field_select_address, field_yes, field_no, referral_already_submitted_page), - (address_select_choice_field_select_address, field_yes, field_yes, referral_already_submitted_page), - (address_select_choice_field_enter_manually, field_no, field_no, address_select_manual_page), - (address_select_choice_field_enter_manually, field_no, field_yes, address_select_manual_page), - (address_select_choice_field_enter_manually, field_yes, field_no, address_select_manual_page), - (address_select_choice_field_enter_manually, field_yes, field_yes, address_select_manual_page), + (address_select_choice_journey_field_select_address, field_no, field_no, council_tax_band_page), + (address_select_choice_journey_field_select_address, field_no, field_yes, council_tax_band_page), + (address_select_choice_journey_field_select_address, field_yes, field_no, referral_already_submitted_page), + (address_select_choice_journey_field_select_address, field_yes, field_yes, referral_already_submitted_page), + (address_select_choice_journey_field_enter_manually, field_no, field_no, address_select_manual_page), + (address_select_choice_journey_field_enter_manually, field_no, field_yes, address_select_manual_page), + (address_select_choice_journey_field_enter_manually, field_yes, field_no, address_select_manual_page), + (address_select_choice_journey_field_enter_manually, field_yes, field_yes, address_select_manual_page), ], ) def test_address_select_not_park_home_next_page(choice, duplicate_uprn, epc_found, expected_next_page): for own_property in own_property_fields_non_social_housing: answers = { - address_select_choice_field: choice, + address_select_choice_journey_field: choice, own_property_field: own_property, park_home_field: field_no, - epc_found_field: epc_found, - duplicate_uprn_field: duplicate_uprn, + epc_found_journey_field: epc_found, + duplicate_uprn_journey_field: duplicate_uprn, } assert get_next_page(address_select_page, answers) == expected_next_page @@ -395,23 +398,23 @@ def test_address_select_not_park_home_next_page(choice, duplicate_uprn, epc_foun @pytest.mark.parametrize( "choice, duplicate_uprn, epc_found, expected_next_page", [ - (address_select_choice_field_select_address, field_no, field_no, no_epc_page), - (address_select_choice_field_select_address, field_no, field_yes, epc_page), - (address_select_choice_field_select_address, field_yes, field_no, referral_already_submitted_page), - (address_select_choice_field_select_address, field_yes, field_yes, referral_already_submitted_page), - (address_select_choice_field_enter_manually, field_no, field_no, address_select_manual_page), - (address_select_choice_field_enter_manually, field_no, field_yes, address_select_manual_page), - (address_select_choice_field_enter_manually, field_yes, field_no, address_select_manual_page), - (address_select_choice_field_enter_manually, field_yes, field_yes, address_select_manual_page), + (address_select_choice_journey_field_select_address, field_no, field_no, no_epc_page), + (address_select_choice_journey_field_select_address, field_no, field_yes, epc_page), + (address_select_choice_journey_field_select_address, field_yes, field_no, referral_already_submitted_page), + (address_select_choice_journey_field_select_address, field_yes, field_yes, referral_already_submitted_page), + (address_select_choice_journey_field_enter_manually, field_no, field_no, address_select_manual_page), + (address_select_choice_journey_field_enter_manually, field_no, field_yes, address_select_manual_page), + (address_select_choice_journey_field_enter_manually, field_yes, field_no, address_select_manual_page), + (address_select_choice_journey_field_enter_manually, field_yes, field_yes, address_select_manual_page), ], ) def test_address_select_social_housing_next_page(choice, duplicate_uprn, epc_found, expected_next_page): answers = { - address_select_choice_field: choice, + address_select_choice_journey_field: choice, own_property_field: own_property_field_social_housing, park_home_field: field_no, - epc_found_field: epc_found, - duplicate_uprn_field: duplicate_uprn, + epc_found_journey_field: epc_found, + duplicate_uprn_journey_field: duplicate_uprn, } assert get_next_page(address_select_page, answers) == expected_next_page @@ -428,9 +431,9 @@ def test_address_manual_next_page(flow, expected_next_page): for flow_answers in get_property_flow_answers(flow): answers = { **flow_answers, - epc_found_field: field_no, - duplicate_uprn_field: field_no, - address_choice_field: address_choice_field_enter_manually, + epc_found_journey_field: field_no, + duplicate_uprn_journey_field: field_no, + address_choice_journey_field: address_choice_journey_field_enter_manually, } assert get_next_page(address_manual_page, answers) == expected_next_page @@ -447,9 +450,9 @@ def test_epc_select_manual_next_page(flow, expected_next_page): for flow_answers in get_property_flow_answers(flow): answers = { **flow_answers, - epc_found_field: field_no, - duplicate_uprn_field: field_no, - epc_select_choice_field: epc_select_choice_field_enter_manually, + epc_found_journey_field: field_no, + duplicate_uprn_journey_field: field_no, + epc_select_choice_journey_field: epc_select_choice_journey_field_enter_manually, } assert get_next_page(epc_select_manual_page, answers) == expected_next_page @@ -466,9 +469,9 @@ def test_address_select_manual_next_page(flow, expected_next_page): for flow_answers in get_property_flow_answers(flow): answers = { **flow_answers, - epc_found_field: field_no, - duplicate_uprn_field: field_no, - address_select_choice_field: address_select_choice_field_enter_manually, + epc_found_journey_field: field_no, + duplicate_uprn_journey_field: field_no, + address_select_choice_journey_field: address_select_choice_journey_field_enter_manually, } assert get_next_page(address_select_manual_page, answers) == expected_next_page @@ -486,7 +489,7 @@ def test_address_select_manual_next_page(flow, expected_next_page): ) def test_referral_already_submitted_next_page(flow, epc_found, expected_next_page): for flow_answers in get_property_flow_answers(flow): - answers = {**flow_answers, epc_found_field: epc_found} + answers = {**flow_answers, epc_found_journey_field: epc_found} assert get_next_page(referral_already_submitted_page, answers) == expected_next_page @@ -500,7 +503,7 @@ def test_referral_already_submitted_next_page(flow, epc_found, expected_next_pag def test_council_tax_band_next_page(epc_found, expected_next_page): for flow_answers in get_property_flow_answers(property_flow_main): for council_tax_band in council_tax_band_fields: - answers = {**flow_answers, council_tax_band_field: council_tax_band, epc_found_field: epc_found} + answers = {**flow_answers, council_tax_band_field: council_tax_band, epc_found_journey_field: epc_found} assert get_next_page(council_tax_band_page, answers) == expected_next_page