def testWorkalendarNames(self): class Woral: get_calendar_holidays = Mock(return_value=[(dt.date(1999, 4, 30), "JOY JOY")]) woral = Woral() hols = Holidays() hols.register(woral) self.assertEqual(hols.names(), ["JOY JOY"])
def testWorkalendar(self): class Woral: get_holiday_label = Mock(return_value="JOY JOY") woral = Woral() hols = Holidays() hols.register(woral) self.assertEqual(hols.srcs, [{}, woral]) self.assertEqual(hols.get(dt.date(1999, 4, 30)), "JOY JOY") woral.get_holiday_label.assert_called_with(dt.date(1999, 4, 30))
def setUp(self): holidays = Holidays(holidaySetting=None) holidays.register(WeatherDays()) self.home = Page.objects.get(slug='home') self.user = User.objects.create_user('i', '*****@*****.**', 's3(r3t') self.calendar = CalendarPage(owner=self.user, slug="events", title="Events") self.calendar.holidays = holidays self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug="committee-meeting", title="Committee Meeting", repeat=Recurrence( dtstart=dt.date(2017, 1, 1), freq=MONTHLY, byweekday=[MO(1), MO(3)]), time_from=dt.time(13), time_to=dt.time(15, 30), holidays=holidays) self.calendar.add_child(instance=self.event)
def testAdd(self): ausHols = Holidays(None) ausHols.add(dt.date(2020, 10, 20), "Kangaroo Day") ausHols.register(AU()) nzHols = Holidays(None) nzHols.add(dt.date(2020, 10, 20), "Kiwi Day") nzHols.register(NZ()) tasHols = ausHols + nzHols self.assertEqual(tasHols.get(dt.date(2020, 10, 20)), "Kangaroo Day, Kiwi Day") self.assertEqual(len(tasHols.srcs), 3) self.assertIs(type(tasHols.srcs[0]), dict) self.assertIs(type(tasHols.srcs[1]), AU) self.assertIs(type(tasHols.srcs[2]), NZ) self.assertEqual(tasHols.names(), [ "New Year's Day", "Day after New Year's Day", "New Year's Day (Observed)", "Day after New Year's Day (Observed)", 'Australia Day', 'Australia Day (Observed)', 'Waitangi Day', 'Waitangi Day (Observed)', 'Good Friday', 'Easter Monday', 'Anzac Day', 'Anzac Day (Observed)', "Queen's Birthday", 'Kangaroo Day', 'Kiwi Day', 'Labour Day', 'Christmas Day', 'Boxing Day', 'Christmas Day (Observed)', 'Boxing Day (Observed)' ])