def test_working_datetime_ranges_of_date_merging_tomorrow(self): d = date(year=1993, month=9, day=26) swh = { d: [ (time(hour=9), time(hour=12)), (time(hour=21), time(hour=0)), ] } wwh_contiguous = { tomorrow(d).weekday(): [ (time(hour=0), time(hour=12)) ] } wwh_separated = { tomorrow(d).weekday(): [ (time(hour=1), time(hour=12)) ] } r_s = working_datetime_ranges_of_date(d, swh, wwh_separated, merge_tomorrow=False) r_s_merged = working_datetime_ranges_of_date(d, swh, wwh_separated, merge_tomorrow=True) r_c = working_datetime_ranges_of_date(d, swh, wwh_contiguous, merge_tomorrow=False) r_c_merged = working_datetime_ranges_of_date(d, swh, wwh_contiguous, merge_tomorrow=True) expected_r_only_today = [ ( datetime(year=1993, month=9, day=26, hour=9), datetime(year=1993, month=9, day=26, hour=12), ), ( datetime(year=1993, month=9, day=26, hour=21), datetime(year=1993, month=9, day=27, hour=0), ) ] expected_r_with_tomorrow = [ ( datetime(year=1993, month=9, day=26, hour=9), datetime(year=1993, month=9, day=26, hour=12), ), ( datetime(year=1993, month=9, day=26, hour=21), datetime(year=1993, month=9, day=27, hour=12), ) ] self.assertEqual(r_s, expected_r_only_today) self.assertEqual(r_s_merged, expected_r_only_today) self.assertEqual(r_c, expected_r_only_today) self.assertEqual(r_c_merged, expected_r_with_tomorrow)
def test_tomorrow_with_datetime(self): dt = datetime(year=2016, month=2, day=29, hour=8, minute=58) expected_dt = datetime(year=2016, month=3, day=1, hour=8, minute=58, second=0, microsecond=0) self.assertEqual(tomorrow(dt), expected_dt)
def test_tomorrow_with_date(self): d = date(year=2016, month=2, day=29) expected_d = date(year=2016, month=3, day=1) self.assertEqual(tomorrow(d), expected_d)