From 764e8dde2947004e6e1aba603cb60988227fe267 Mon Sep 17 00:00:00 2001 From: Sam Greenbury Date: Sun, 15 Oct 2023 15:47:06 +0100 Subject: [PATCH] Add tests --- python/tests/test_reader.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 python/tests/test_reader.py diff --git a/python/tests/test_reader.py b/python/tests/test_reader.py new file mode 100644 index 0000000..e58ef3a --- /dev/null +++ b/python/tests/test_reader.py @@ -0,0 +1,30 @@ +from uatk_spc.reader import SPCReaderParquet as SPCReader +import pathlib +import os + + +def get_path(): + return pathlib.Path(os.path.abspath(__file__)).parent.joinpath("data/") + + +TEST_REGION = "test_region" +TEST_PATH = get_path() + + +def test_reader(): + spc = SPCReader(TEST_PATH, TEST_REGION) + print(spc.people) + assert spc.people.shape[0] == 4991 + + +def test_merge_people_and_time_use_diaries(): + spc = SPCReader(TEST_PATH, TEST_REGION) + merged = spc.merge_people_and_time_use_diaries( + {"health": ["bmi"], "demographics": ["age_years"]}, diary_type="weekday_diaries" + ) + assert merged.shape == (197_397, 30) + +def test_merge_people_and_households(): + spc = SPCReader(TEST_PATH, TEST_REGION) + merged = spc.merge_people_and_households() + assert merged.shape == (4991, 18)