removing s3 calls from unit tests

This commit is contained in:
Khalim Conn-Kowlessar 2025-05-15 16:50:12 +01:00
parent b53e172d7c
commit eb35ea49ff
4 changed files with 13 additions and 16 deletions

View file

@ -1,3 +1,4 @@
import pickle
import pytest
from utils.s3 import read_dataframe_from_s3_parquet
from etl.epc.Record import EPCRecord
@ -7,13 +8,12 @@ import random
class TestEpcRecord:
@pytest.fixture()
@pytest.fixture
def cleaning_data(self):
cleaning_data = read_dataframe_from_s3_parquet(
bucket_name="retrofit-data-dev", file_key="sap_change_model/cleaning_dataset.parquet",
)
with open("recommendations/tests/test_data/cleaning_data.pkl", "rb") as f:
data = pickle.load(f)
return cleaning_data
return data
@pytest.fixture()
def epc_records_1(self):
@ -262,7 +262,7 @@ class TestEpcRecord:
record.full_sap_epc = []
record._clean_number_lighting_outlets()
assert record.prepared_epc["fixed-lighting-outlets-count"] == 8.0
assert record.prepared_epc["fixed-lighting-outlets-count"] == 10
def test_clean_count_variables(self, cleaning_data):
record = EPCRecord(cleaning_data=cleaning_data)

Binary file not shown.

Binary file not shown.

View file

@ -1,7 +1,6 @@
from datetime import datetime
import pandas as pd
import msgpack
from utils.s3 import read_dataframe_from_s3_parquet, read_from_s3
import pickle
import pytest
from backend.Property import Property
from etl.epc.Record import EPCRecord
@ -14,18 +13,16 @@ class TestHeatingRecommendations:
@pytest.fixture
def cleaning_data(self):
return read_dataframe_from_s3_parquet(
bucket_name="retrofit-data-dev", file_key="sap_change_model/cleaning_dataset.parquet",
)
with open("recommendations/tests/test_data/cleaning_data.pkl", "rb") as f:
data = pickle.load(f)
return data
@pytest.fixture
def cleaned(self):
df = read_from_s3(
s3_file_name="cleaned_epc_data/cleaned.bson",
bucket_name="retrofit-data-dev"
)
with open("recommendations/tests/test_data/cleaned.pkl", "rb") as f:
df = pickle.load(f)
df = msgpack.unpackb(df, raw=False)
return df
@pytest.fixture