class TestInterfaceED(): """ import example data - check correct sizes - columns in df """ def setup(self): print("setup Interface and load data files.") self.hosp = Interface('./flosp/test/data/simpleday/setup.py') self.hosp.load_dataED('./flosp/test/data/simpleday/SimpleED.csv' ) # note this path makes it important which dir def test_dataED_shape(self): """check size of dataframes, check all expected columns exist etc. Is this useful for checks module too? Is this all reproduced in test_io""" assert self.hosp.data.ED.shape == (24, 41) def test_extract_dataED(self): """check returns dataframe object, with valid and invalid inputs""" pass
class TestInterfaceLoadED(): """ import example data - check correct sizes - columns in df """ def setup(self): print("setup class:TestStuff") from flosp.interface import Interface self.hosp = Interface('./example/setup.py') self.hosp.load_dataED( './example/example_data_ED.csv' ) # note this path makes it important which dir pytest is run def test_load_dataED(self): """check size of dataframes, check all expected columns exist etc. Is this useful for checks module too? Is this all reproduced in test_io""" pass def test_extract_dataED(self): """check returns dataframe object, with valid and invalid inputs""" pass
class TestAgg(): """ Testing of aggregation functions for simple day example data. """ def setup(self): print ("Get some data.") self.hosp = Interface('./flosp/test/data/simpleday/setup.py') self.hosp.load_dataED('./flosp/test/data/simpleday/SimpleED.csv') # note this path makes it important which dir self.hosp.make_new_tables() def test_hourly_IPocc_total(self): """ Test occupancy calcs, flosp vs. manual check with function from this test file. This is really testing that the flosp aggregation of occupancy calcs is correct, rather than the calculation of occupancy itself. """ #### get list of datetimes to test hours_list = get_datetimes_list(self.hosp.data.IPSPELL, 'ADM_DTTM') df_flosp = self.hosp.data.HOURLY for datetime_hour in hours_list: occ_value = get_occ_hour_athour(self.hosp.data.IPSPELL, 'ADM_DTTM', 'DIS_DTTM', datetime_hour) assert occ_value == df_flosp.loc[datetime_hour].IPocc_total return def test_hourly_IPocc_nonelec(self): """ Test occupancy calcs, flosp vs. manual check with function from this test file. """ #### get list of datetimes to df = self.hosp.data.IPSPELL dff = df.query('ADM_TYPE in ["Non-Elective"]') hours_list = get_datetimes_list(dff, 'ADM_DTTM') df_flosp = self.hosp.data.HOURLY for datetime_hour in hours_list: occ_value = get_occ_hour_athour(dff, 'ADM_DTTM', 'DIS_DTTM', datetime_hour) assert occ_value == df_flosp.loc[datetime_hour].IPocc_nonelec return def test_hourly_EDocc_total(self): """ Test occupancy calcs, flosp vs. manual check with function from this test file. """ #### get list of datetimes to df = self.hosp.data.ED dff = df # dff = df.query('ADM_TYPE in ["Non-Elective"]') hours_list = get_datetimes_list(dff, 'ARRIVAL_DTTM') df_flosp = self.hosp.data.HOURLY for datetime_hour in hours_list: # occ_value = get_occ_hour_inwindow(dff, 'ARRIVAL_DTTM', 'DEPARTURE_DTTM', datetime_hour) occ_value = get_occ_hour_athour(dff, 'ARRIVAL_DTTM', 'DEPARTURE_DTTM', datetime_hour) assert occ_value == df_flosp.loc[datetime_hour].EDocc_total return def test_(self): """check returns dataframe object, with valid and invalid inputs""" pass