def test_daily_dataframe_verification_raises_error_for_dates_with_repeating_timeslots(self): test_df = pd.DataFrame( data=[ {'v': 1}, {'v': 1}, {'v': 1}, {'v': 1}, {'v': 1}, {'v': 1}, {'v': 1}, ], index=[ dt.datetime(2020,1,1,0,0), dt.datetime(2020,1,1,1,0), dt.datetime(2020,1,2,0,0), dt.datetime(2020,1,2,1,0), dt.datetime(2020,1,2,1,0), dt.datetime(2020,1,3,0,0), dt.datetime(2020,1,3,1,0), ] ) with pytest.raises(InvalidTimeSlots) as e: daily_dataframe.verify_data_integrity(test_df, [dt.time(0,0), dt.time(1,0)]) error_message = str(e.value) assert 'datetime.date(2020, 1, 2)' in error_message
def test_daily_dataframe_verification_raises_error_for_real_dataset_with_local_DST_included_time(self): test_df = pd.read_hdf('tests/test_data/manually_processed_dataframes', key='raw_df') test_df.set_index(test_df.index.tz_localize(None), inplace=True) time_slots = [dt.time(i,0) for i in range(24)] with pytest.raises(InvalidTimeSlots) as e: daily_dataframe.verify_data_integrity(test_df, time_slots) error_message = str(e.value) assert 'datetime.date(2015, 3, 29)' in error_message assert 'datetime.date(2015, 10, 25)' in error_message assert 'datetime.date(2016, 3, 27)' in error_message assert 'datetime.date(2016, 10, 30)' in error_message assert 'datetime.date(2017, 3, 26)' in error_message assert 'datetime.date(2017, 10, 29)' in error_message assert 'datetime.date(2018, 3, 25)' in error_message assert 'datetime.date(2018, 10, 28)' in error_message assert 'datetime.date(2019, 3, 31)' in error_message assert 'datetime.date(2019, 10, 27)' in error_message
def test_daily_dataframe_raises_error_for_non_contiguous_dates(self): test_df = pd.DataFrame( data=[ {'v': 1}, {'v': 1}, {'v': 1}, {'v': 1}, ], index=[ dt.datetime(2020,1,1,0,0), dt.datetime(2020,1,1,2,0), dt.datetime(2020,1,3,0,0), dt.datetime(2020,1,3,2,0), ] ) with pytest.raises(MoreThanOneContiguousDatapoint) as e: daily_dataframe.verify_data_integrity(test_df, [dt.time(0,0), dt.time(2,0)]) error_message = str(e.value) assert '(datetime.date(2020, 1, 1), datetime.date(2020, 1, 1))' in error_message assert '(datetime.date(2020, 1, 3), datetime.date(2020, 1, 3))' in error_message
def test_daily_dataframe_verification_works_for_correct_dataframe(self): test_df = pd.DataFrame( data=[ {'v': 1}, {'v': 1}, {'v': 1}, {'v': 1}, {'v': 1}, {'v': 1}, ], index=[ dt.datetime(2020,1,1,0,0), dt.datetime(2020,1,1,1,0), dt.datetime(2020,1,2,0,0), dt.datetime(2020,1,2,1,0), dt.datetime(2020,1,3,0,0), dt.datetime(2020,1,3,1,0), ] ) assert daily_dataframe.verify_data_integrity(test_df, [dt.time(0,0), dt.time(1,0)]) == ( dt.date(2020,1,1), dt.date(2020,1,3), )