Model/model_data/tests/test_epc_clean.py
2023-06-15 15:05:50 +01:00

31 lines
964 B
Python

import pytest
import pickle
from model_data.EpcClean import EpcClean
from pathlib import Path
# For local testing
if __file__ == "<input>":
input_data_path = Path("./model_data/tests/test_data/EpcClean_inputs.obj")
else:
current_file_path = Path(__file__)
input_data_path = current_file_path.parent / 'test_data' / 'EpcClean_inputs.obj'
class TestEpcClean:
@staticmethod
def load_data(path):
with open(path, "rb") as file:
return pickle.load(file)
@pytest.fixture(autouse=True)
def setup_class(self):
self.cleaner = EpcClean(self.load_data(input_data_path))
def test_clean(self):
self.cleaner.clean()
assert len(self.cleaner.cleaned["roof-description"]) == len(self.cleaner.unique_vals["roof-description"])
def test__init_empty_cleaned_obj(self):
self.cleaner._init_empty_cleaned_obj()
assert all([len(values) == 0 for values in self.cleaner.cleaned.values()])