mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
sanity check to ensure price matrix is correct format
This commit is contained in:
parent
329e3425c4
commit
738c5f915e
2 changed files with 37 additions and 14 deletions
|
|
@ -56,14 +56,14 @@ class SurveyPrice():
|
|||
df = pd.read_excel(self.master_rate_card_path, sheet_name)
|
||||
|
||||
columns_to_check = {
|
||||
"no extractors or ventilation required": {"Trickle Vent": 0, "wetrooms": 0},
|
||||
"Trickle Vents ONLY": {"Trickle Vent": 1, "wetrooms": 0},
|
||||
"1 wet room extractor required": {"Trickle Vent": 0, "wetrooms": 1},
|
||||
"2 wet room extractor required": {"Trickle Vent": 0, "wetrooms": 2},
|
||||
"3 wet room extractor required": {"Trickle Vent": 0, "wetrooms": 3},
|
||||
'Trickle Vents + 1 wet room extractor': {"Trickle Vent": 1, "wetrooms": 1},
|
||||
'Trickle Vents + 2 wet room extractor': {"Trickle Vent": 1, "wetrooms": 2},
|
||||
'Trickle Vents + 3 wet room extractor': {"Trickle Vent": 1, "wetrooms": 3},
|
||||
"no extractors or ventilation required": {"Trickle Vent": 0, "Wetrooms": 0},
|
||||
"Trickle Vents ONLY": {"Trickle Vent": 1, "Wetrooms": 0},
|
||||
"1 wet room extractor required": {"Trickle Vent": 0, "Wetrooms": 1},
|
||||
"2 wet room extractor required": {"Trickle Vent": 0, "Wetrooms": 2},
|
||||
"3 wet room extractor required": {"Trickle Vent": 0, "Wetrooms": 3},
|
||||
'Trickle Vents + 1 wet room extractor': {"Trickle Vent": 1, "Wetrooms": 1},
|
||||
'Trickle Vents + 2 wet room extractor': {"Trickle Vent": 1, "Wetrooms": 2},
|
||||
'Trickle Vents + 3 wet room extractor': {"Trickle Vent": 1, "Wetrooms": 3},
|
||||
}
|
||||
|
||||
pricing_table = []
|
||||
|
|
@ -71,10 +71,10 @@ class SurveyPrice():
|
|||
for key, variables in columns_to_check.items():
|
||||
pricing_table.append(
|
||||
{
|
||||
"funding": row["Funding"],
|
||||
"floor_area_group": row["Total Floor Area"][:-1],
|
||||
"WORK TYPE": row["WORK TYPE"],
|
||||
"Floor Area Group": row["Total Floor Area"][:-1],
|
||||
**variables,
|
||||
"price": row[key][1:] if row[key] != "Not viable" else None,
|
||||
"PRICE": row[key] if row[key] != "Not viable" else None,
|
||||
}
|
||||
)
|
||||
pricing_table = pd.DataFrame(pricing_table)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,32 @@ os.environ["SHAREPOINT_CLIENT_SECRET"] = "SOf8Q~-is4wdQiqvEEm9FlJQRAY9ELGaj5Qz-a
|
|||
os.environ["SHAREPOINT_TENANT_ID"] = "c3f7519c-2719-4547-af04-6da6cbfd8f8f"
|
||||
|
||||
from etl.surveyPrice.surveyPrice import SurveyPrice
|
||||
import pytest
|
||||
|
||||
def test_get_price_matrix_jjc_empties():
|
||||
sp = SurveyPrice
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def sp():
|
||||
return SurveyPrice()
|
||||
|
||||
|
||||
def cavity_price_dataframe_sanity_check(df):
|
||||
assert df.shape == (160, 5)
|
||||
assert df.columns.tolist() == ['WORK TYPE', 'Floor Area Group', 'Trickle Vent', 'Wetrooms', 'PRICE']
|
||||
|
||||
def test_get_price_matrix_jjc_empties(sp):
|
||||
jjc_empties_price_table = sp.get_cavity_pricing_table("JJC - EMPTIES")
|
||||
|
||||
cavity_price_dataframe_sanity_check(jjc_empties_price_table)
|
||||
|
||||
def test_get_price_matrix_jjc_general_extraction(sp):
|
||||
sp = SurveyPrice()
|
||||
jjc_empties_price_table = sp.get_cavity_pricing_table("JJC - GENERAL EXTRACTIONS")
|
||||
cavity_price_dataframe_sanity_check(jjc_empties_price_table)
|
||||
|
||||
def test_get_price_matrix_jjc_foam(sp):
|
||||
sp = SurveyPrice()
|
||||
jjc_empties_price_table = sp.get_cavity_pricing_table("JJC - FORMALDEHYDE EXTRACTION")
|
||||
cavity_price_dataframe_sanity_check(jjc_empties_price_table)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue