def testFindDaysToExclude(self):
     day_week_exclude = [
         '2020/10/10', '2020/11/10-2020/12/10', '2020/08/10'
     ]
     days_to_remove = utils.find_days_to_exclude(day_week_exclude)
     expected_days = [
         TimeWindow(pd.Timestamp('2020-10-10'), pd.Timestamp('2020-10-10')),
         TimeWindow(pd.Timestamp('2020-11-10'), pd.Timestamp('2020-12-10')),
         TimeWindow(pd.Timestamp('2020-08-10'), pd.Timestamp('2020-08-10')),
     ]
     for x in range(len(expected_days)):
         self.assertEqual(days_to_remove[x].first_day,
                          expected_days[x].first_day)
         self.assertEqual(days_to_remove[x].last_day,
                          expected_days[x].last_day)
 def testExpandTimeWindows(self):
     day_week_exclude = [
         '2020/10/10', '2020/11/10-2020/12/10', '2020/08/10'
     ]
     days_to_remove = utils.find_days_to_exclude(day_week_exclude)
     periods = utils.expand_time_windows(days_to_remove)
     expected = [
         pd.Timestamp('2020-10-10', freq='D'),
         pd.Timestamp('2020-08-10', freq='D'),
     ]
     expected += pd.date_range(start='2020-11-10',
                               end='2020-12-10',
                               freq='D')
     self.assertEqual(len(periods), len(expected))
     for x in periods:
         self.assertIn(x, expected)
    def testWrongDateFormat(self):
        incorrect_day = ['2020/13/13', '2020/03/03']
        with self.assertRaises(ValueError):
            utils.find_days_to_exclude(incorrect_day)

        incorrect_time_window = ['2020/10/13 - 2020/13/11', '2020/03/03']
        with self.assertRaises(ValueError):
            utils.find_days_to_exclude(incorrect_time_window)

        incorrect_format = ['2020/10/13 - 2020/13/11 . 2020/10/10']
        with self.assertRaises(ValueError):
            utils.find_days_to_exclude(incorrect_format)