mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
64 lines
2.3 KiB
Python
64 lines
2.3 KiB
Python
import pytest
|
|
import pandas as pd
|
|
from utils.s3 import read_csv_from_s3
|
|
from backend.Funding import Funding
|
|
|
|
|
|
def get_funding_data():
|
|
"""
|
|
This function retrieves the eco project scores matrix and the warm homes local grant funding data
|
|
:return:
|
|
"""
|
|
project_scores_matrix = read_csv_from_s3(
|
|
bucket_name="retrofit-data-dev",
|
|
filepath="funding/ECO4 Full Project Scores Matrix.csv",
|
|
)
|
|
project_scores_matrix = pd.DataFrame(project_scores_matrix)
|
|
project_scores_matrix.columns = ['Floor Area Segment', 'Starting Band', 'Finishing Band', 'Cost Savings']
|
|
project_scores_matrix["Cost Savings"] = project_scores_matrix["Cost Savings"].astype(float)
|
|
|
|
partial_project_scores_matrix = read_csv_from_s3(
|
|
bucket_name="retrofit-data-dev",
|
|
filepath="funding/ECO4_Partial_Project_Scores_Matrix_v6.csv",
|
|
)
|
|
partial_project_scores_matrix = pd.DataFrame(partial_project_scores_matrix)
|
|
partial_project_scores_matrix["Cost Savings"] = partial_project_scores_matrix["Cost Savings"].astype(float)
|
|
|
|
whlg_eligible_postcodes = read_csv_from_s3(
|
|
bucket_name="retrofit-data-dev",
|
|
filepath="funding/whlg eligible postcodes.csv",
|
|
)
|
|
whlg_eligible_postcodes = pd.DataFrame(whlg_eligible_postcodes)
|
|
|
|
return project_scores_matrix, partial_project_scores_matrix, whlg_eligible_postcodes
|
|
|
|
|
|
class TestFunding:
|
|
|
|
def test_prs(self):
|
|
fps_matrix, pps_matrix, whlg_eligible_postcodes = get_funding_data()
|
|
funding = Funding(
|
|
project_scores_matrix=fps_matrix,
|
|
partial_project_scores_matrix=pps_matrix,
|
|
whlg_eligible_postcodes=whlg_eligible_postcodes,
|
|
social_cavity_abs_rate=13.5,
|
|
social_solid_abs_rate=17,
|
|
private_cavity_abs_rate=13.5,
|
|
private_solid_abs_rate=17,
|
|
tenure="Private",
|
|
)
|
|
|
|
measures_1 = [
|
|
{"type": "internal_wall_insulation", "is_innovation": False},
|
|
{"type": "solar_pv", "is_innovation": True},
|
|
]
|
|
|
|
funding.check_funding(
|
|
measures=measures_1,
|
|
starting_sap=54,
|
|
ending_sap=69,
|
|
floor_area=73,
|
|
mainheat_description="Boiler and radiators, mains gas",
|
|
heating_control_description="Programmer, room thermostat and TRVs",
|
|
is_cavity=True
|
|
)
|