Skip to content

Commit

Permalink
Merge pull request #414 from UKGovernmentBEIS/staging
Browse files Browse the repository at this point in the history
Staging -> Main
  • Loading branch information
Glenn-Clarke authored Dec 17, 2024
2 parents fba0987 + deb4768 commit 414786f
Show file tree
Hide file tree
Showing 18 changed files with 1,197 additions and 643 deletions.
61 changes: 38 additions & 23 deletions help_to_heat/frontdoor/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
country_page = "country"
northern_ireland_ineligible_page = "northern-ireland"
supplier_page = "supplier"
alternative_supplier_page = "alternative-supplier"
own_property_page = "own-property"
bulb_warning_page = "bulb-warning-page"
shell_warning_page = "shell-warning-page"
Expand Down Expand Up @@ -43,6 +44,7 @@
country_page,
northern_ireland_ineligible_page,
supplier_page,
alternative_supplier_page,
own_property_page,
bulb_warning_page,
shell_warning_page,
Expand Down Expand Up @@ -91,6 +93,8 @@
country_field_wales = "Wales"
country_field_northern_ireland = "Northern Ireland"

# if needing to query this, in most cases use SupplierConverter.get_supplier()
# it handles the user selecting an alternative
supplier_field = "supplier"
supplier_field_british_gas = "British Gas"
supplier_field_bulb = "Bulb, now part of Octopus Energy"
Expand All @@ -104,7 +108,7 @@
supplier_field_shell = "Shell"
supplier_field_utilita = "Utilita"
supplier_field_utility_warehouse = "Utility Warehouse"
supplier_fields = [
supplier_field_values_real = [
supplier_field_british_gas,
supplier_field_bulb,
supplier_field_e,
Expand All @@ -118,6 +122,10 @@
supplier_field_utilita,
supplier_field_utility_warehouse,
]
supplier_field_not_listed = "supplier_not_listed"

alternative_supplier_field = "alternative_supplier"

user_selected_supplier_field = "user_selected_supplier"

bulb_warning_page_field = "confirm_bulb_warning"
Expand All @@ -131,7 +139,7 @@
own_property_field_tenant = "No, I am a tenant"
own_property_field_social_housing = "No, I am a social housing tenant"
own_property_field_landlord = "Yes, I am the property owner but I lease the property to one or more tenants"
own_property_fields_non_social_housing = [
own_property_field_values_non_social_housing = [
own_property_field_own_property,
own_property_field_tenant,
own_property_field_landlord,
Expand All @@ -143,33 +151,40 @@
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"
address_all_address_and_lmk_details_field = "address_and_lmk_details"

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"

address_select_choice_field = "address_select_choice"
address_select_choice_field_select_address = "select address"
address_select_choice_field_enter_manually = "enter manually"

referral_already_submitted_field = "submit_another"
# 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"

# 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

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"

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"
address_manual_town_or_city_field = "town_or_city"
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" # yes/no options
epc_found_journey_field = "epc_found" # yes/no options
lmk_field = "lmk"
lmk_field_enter_manually = "enter-manually"
address_field = "address"
Expand All @@ -189,7 +204,7 @@
council_tax_band_field_g = "G"
council_tax_band_field_h = "H"
council_tax_band_field_i = "I"
council_tax_band_fields = [
council_tax_band_field_values = [
council_tax_band_field_a,
council_tax_band_field_b,
council_tax_band_field_c,
Expand All @@ -205,9 +220,9 @@
epc_accept_suggested_epc_field_not_found = "Not found"
epc_rating_field = "epc_rating"
epc_rating_field_not_found = "Not found"
epc_rating_is_eligible_field = "epc_rating_is_eligible"
epc_rating_is_eligible_field = "epc_rating_is_eligible" # yes/no options

no_epc_field = "confirm_no_epc"
no_epc_field = "confirm_no_epc" # yes/no options

benefits_field = "benefits"

Expand Down
54 changes: 45 additions & 9 deletions help_to_heat/frontdoor/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from . import models, schemas
from .consts import (
all_pages,
alternative_supplier_field,
alternative_supplier_page,
confirm_and_submit_page,
epc_accept_suggested_epc_field,
epc_accept_suggested_epc_field_not_found,
Expand All @@ -34,6 +36,13 @@
property_type_field,
property_type_field_park_home,
supplier_field,
supplier_field_bulb,
supplier_field_eon_next,
supplier_field_not_listed,
supplier_field_octopus,
supplier_field_shell,
supplier_field_utility_warehouse,
supplier_page,
)
from .epc_api import EPCApi
from .os_api import OSApi, ThrottledApiException
Expand Down Expand Up @@ -161,38 +170,65 @@ def get_addresses_from_api(postcode):
class SupplierConverter:
def __init__(self, session_id):
self.session_id = session_id
self.supplier = None
self.alternative_supplier = None

def _get_supplier(self):
return api.session.get_answer(self.session_id, "supplier")["supplier"]
def get_supplier(self):
supplier = self._get_supplier_from_session()
alternative_supplier = self._get_alternative_supplier_from_session()

return alternative_supplier if self._did_specify_alternative() else supplier

def _get_supplier_from_session(self):
if self.supplier is None:
self.supplier = api.session.get_answer(self.session_id, supplier_page).get(supplier_field)

return self.supplier

def _get_alternative_supplier_from_session(self):
if self.alternative_supplier is None:
self.alternative_supplier = api.session.get_answer(self.session_id, alternative_supplier_page).get(
alternative_supplier_field
)

return self.alternative_supplier

def _did_specify_alternative(self):
supplier = self._get_supplier_from_session()
return supplier == supplier_field_not_listed

def _is_bulb(self):
return self._get_supplier() == "Bulb, now part of Octopus Energy"
return self.get_supplier() == supplier_field_bulb

def _is_utility_warehouse(self):
return self._get_supplier() == "Utility Warehouse"
return self.get_supplier() == supplier_field_utility_warehouse

def _is_shell(self):
return self._get_supplier() == "Shell"
return self.get_supplier() == supplier_field_shell

def get_supplier_on_general_pages(self):
supplier = self._get_supplier()
supplier = self.get_supplier()
if self._is_bulb():
return supplier + ", "
return supplier

def get_supplier_on_success_page(self):
supplier = self._get_supplier()
supplier = self.get_supplier()
if self._is_bulb() or self._is_shell():
return "Octopus Energy"
if self._is_utility_warehouse():
return "E.ON Next"
return supplier

def replace_in_session_data(self, session_data):
if self._did_specify_alternative():
alternative_supplier = self._get_alternative_supplier_from_session()
session_data[supplier_field] = alternative_supplier

if self._is_bulb() or self._is_shell():
session_data["supplier"] = "Octopus Energy"
session_data[supplier_field] = supplier_field_octopus
if self._is_utility_warehouse():
session_data["supplier"] = "E.ON Next"
session_data[supplier_field] = supplier_field_eon_next
return session_data


Expand Down
5 changes: 5 additions & 0 deletions help_to_heat/frontdoor/mock_epc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def get_epc_recommendations(self, lmk_key):
return load_test_reponse("sample_epc_recommendations_response.json")


class MockEPCApiWithMultipleEPC(MockEPCApi):
def search_epc_details(self, building, postcode):
return load_test_reponse("sample_search_response_with_multiple_epc.json")


class MockEPCApiWithEPCC(MockEPCApi):
def get_epc_details(self, rrn):
epc = load_test_reponse("sample_epc_response.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,100 +281,6 @@
"low-energy-lighting": "0",
"walls-description": "Sandstone, as built, no insulation (assumed)",
"hotwater-description": "Electric immersion, standard tariff"
},
{
"low-energy-fixed-light-count": "",
"address": "22 Acacia Avenue, Upper Wellgood, Fulchester, FL23 4JA",
"uprn-source": "Address Matched",
"floor-height": "2.833",
"heating-cost-potential": "1100",
"unheated-corridor-length": "2.05",
"hot-water-cost-potential": "166",
"construction-age-band": "England and Wales: before 1900",
"potential-energy-rating": "F",
"mainheat-energy-eff": "Very Poor",
"windows-env-eff": "Average",
"lighting-energy-eff": "Very Poor",
"environment-impact-potential": "28",
"glazed-type": "double glazing, unknown install date",
"heating-cost-current": "1916",
"address3": "",
"mainheatcont-description": "Programmer and appliance thermostats",
"sheating-energy-eff": "N/A",
"property-type": "Maisonette",
"local-authority-label": "Westminster",
"fixed-lighting-outlets-count": "",
"energy-tariff": "Unknown",
"mechanical-ventilation": "natural",
"hot-water-cost-current": "365",
"county": "Greater London Authority",
"postcode": "FL23 4JA",
"solar-water-heating-flag": "N",
"constituency": "E14000639",
"co2-emissions-potential": "9.9",
"number-heated-rooms": "3",
"floor-description": "(other premises below)",
"energy-consumption-potential": "602",
"local-authority": "E09000033",
"built-form": "NO DATA!",
"number-open-fireplaces": "0",
"windows-description": "Fully double glazed",
"glazed-area": "Normal",
"inspection-date": "2010-07-20",
"mains-gas-flag": "N",
"co2-emiss-curr-per-floor-area": "81",
"address1": "22 Acacia Avenue",
"heat-loss-corridor": "unheated corridor",
"flat-storey-count": "5.0",
"constituency-label": "Cities of London and Westminster",
"roof-energy-eff": "Very Poor",
"total-floor-area": "109.021",
"building-reference-number": "8502528768",
"environment-impact-current": "33",
"co2-emissions-current": "8.8",
"roof-description": "Pitched, no insulation (assumed)",
"floor-energy-eff": "N/A",
"number-habitable-rooms": "3",
"address2": "Upper Wellgood",
"hot-water-env-eff": "Poor",
"posttown": "Fulchester",
"mainheatc-energy-eff": "Good",
"main-fuel": "electricity - this is for backwards compatibility only and should not be used",
"lighting-env-eff": "Very Poor",
"windows-energy-eff": "Average",
"floor-env-eff": "N/A",
"sheating-env-eff": "N/A",
"lighting-description": "No low energy lighting",
"roof-env-eff": "Very Poor",
"walls-energy-eff": "Very Poor",
"photo-supply": "0.0",
"lighting-cost-potential": "136",
"mainheat-env-eff": "Poor",
"multi-glaze-proportion": "100",
"main-heating-controls": "2603",
"lodgement-datetime": "2010-07-20 16:38:12",
"flat-top-storey": "Y",
"current-energy-rating": "G",
"secondheat-description": "None",
"walls-env-eff": "Very Poor",
"transaction-type": "rental (private)",
"uprn": "001234567890",
"current-energy-efficiency": "8",
"energy-consumption-current": "538",
"mainheat-description": "Room heaters, electric",
"lighting-cost-current": "121",
"lodgement-date": "2010-07-20",
"extension-count": "0",
"mainheatc-env-eff": "Good",
"lmk-key": "333333333333333333333333333333333",
"wind-turbine-count": "0",
"tenure": "rental (private)",
"floor-level": "3rd",
"potential-energy-efficiency": "35",
"hot-water-energy-eff": "Very Poor",
"low-energy-lighting": "0",
"walls-description": "Sandstone, as built, no insulation (assumed)",
"hotwater-description": "Electric immersion, standard tariff"
}
]
}
Loading

0 comments on commit 414786f

Please sign in to comment.