def setUp(self): self.home = Page.objects.get(slug='home') self.user = User.objects.create_user('i', '*****@*****.**', 's3(r3t') self.calendar = CalendarPage(owner=self.user, slug="schedule", title="Schedule") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = MultidayRecurringEventPage( slug="test-session", title="Test Session", repeat=Recurrence(dtstart=dt.date(2018, 1, 8), freq=WEEKLY, byweekday=[MO], until=dt.date(2018, 4, 25)), num_days=3, time_from=dt.time(10), time_to=dt.time(12, 30)) self.calendar.add_child(instance=self.event) self.info = ExtraInfoPage(owner=self.user, overrides=self.event, except_date=dt.date(2018, 2, 12), extra_title="System Demo", extra_information="<h3>System Demo</h3>") self.event.add_child(instance=self.info) self.info.save_revision().publish()
def setUp(self): 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.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug="test-meeting", title="Test Meeting", repeat=Recurrence( dtstart=dt.date(2010, 1, 1), freq=WEEKLY, byweekday=[MO, WE, FR]), time_from=dt.time(13), time_to=dt.time(14, 30)) self.calendar.add_child(instance=self.event) self.shutdown = ExtCancellationPage( owner=self.user, overrides=self.event, cancelled_from_date=dt.date(2020, 3, 20), cancelled_to_date=dt.date(2020, 6, 1), cancellation_title="No Meeting during Shutdown") self.event.add_child(instance=self.shutdown) self.shutdown.save_revision().publish()
def setUp(self): translation.activate('de') self.home = Page.objects.get(slug='home') self.user = User.objects.create_user('i', '*****@*****.**', 's3(r3t') self.calendar = CalendarPage(owner=self.user, slug="ereignisse", title="Ereignisse") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug="meeting", title="Testen Sie Meeting", repeat=Recurrence( dtstart=dt.date(1988, 1, 1), freq=WEEKLY, byweekday=[MO, WE, FR]), time_from=dt.time(13), time_to=dt.time(15, 30)) self.calendar.add_child(instance=self.event) self.info = ExtraInfoPage(owner=self.user, overrides=self.event, except_date=dt.date(1999, 1, 5), extra_title="Freitag", extra_information="Besonderer Freitag") self.event.add_child(instance=self.info) self.info.save_revision().publish()
def setUp(self): imgFile = get_test_image_file() imgFile.name = "logo.png" self.img = Image.objects.create(title="Logo", file=imgFile) imgName = os.path.splitext(os.path.basename(self.img.file.name))[0] self.rendName = "{}.width-350.format-png.png".format(imgName) Site.objects.update(hostname="joy.test") self.home = Page.objects.get(slug='home') self.user = User.objects.create_user('i', '*****@*****.**', 's3(R3t') self.requestFactory = RequestFactory() self.calendar = CalendarPage(owner = self.user, slug = "events", title = "Events") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(owner = self.user, slug = "workshop", title = "Workshop", image = self.img, repeat = Recurrence(dtstart=dt.date(2017,1,1), freq=MONTHLY, byweekday=[TU(1)], until=dt.date(2017,12,26))) self.calendar.add_child(instance=self.event) self.event.save_revision().publish() self.handler = RssHandler()
def setUp(self): 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.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug="test-meeting", title="Test Meeting", repeat=Recurrence( dtstart=dt.date(1989, 1, 1), freq=WEEKLY, byweekday=[MO, WE, FR]), time_from=dt.time(13), time_to=dt.time(15, 30), holidays=self.calendar.holidays) self.calendar.add_child(instance=self.event) self.closedHols = ClosedForHolidaysPage( owner=self.user, overrides=self.event, all_holidays=True, holidays=self.calendar.holidays) self.event.add_child(instance=self.closedHols) self.closedHols.save_revision().publish()
def setUp(self): 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.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug="test-meeting", title="Test Meeting", repeat=Recurrence( dtstart=dt.date(1989, 1, 1), freq=WEEKLY, byweekday=[MO, WE, FR]), time_from=dt.time(13), time_to=dt.time(15, 30)) self.calendar.add_child(instance=self.event) self.cancellation = CancellationPage( owner=self.user, overrides=self.event, except_date=dt.date(1989, 2, 1), cancellation_title="Meeting Cancelled", cancellation_details="Cancelled due to lack of interest") self.event.add_child(instance=self.cancellation) self.cancellation.save_revision().publish()
def setUp(self): if WagtailVersion > (2, 13, 0): self.FIELD_CONTENT = """ <div data-contentpath="num_days"> {} {} </div> """.format(self.FIELDSET_CONTENT, self.COMMENT_CONTROL_CONTENT) else: self.FIELD_CONTENT = self.FIELDSET_CONTENT self.maxDiff = None self.home = getPage("/home/") self.user = User.objects.create_superuser('i', '*****@*****.**', 's3(r3t') self.calendar = CalendarPage(owner=self.user, slug="events", title="Events") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug="leaders-meeting", title="Leaders' Meeting", repeat=Recurrence(dtstart=dt.date( 2016, 2, 16), freq=MONTHLY, byweekday=[TU(3)]), time_from=dt.time(19), tz="Asia/Tokyo") self.calendar.add_child(instance=self.event) self.event.save_revision().publish() Form = get_form_for_model(RecurringEventPage, form_class=RecurringEventPageForm) self.form = Form(instance=self.event, parent_page=self.calendar)
class TestTZ(TestCase): def setUp(self): 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.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug="test-meeting", title="Test Meeting", repeat=Recurrence( dtstart=dt.date(1989, 1, 1), freq=WEEKLY, byweekday=[MO, WE, FR]), time_from=dt.time(13, 30), time_to=dt.time(16), tz=pytz.timezone("US/Eastern")) self.calendar.add_child(instance=self.event) self.cancellation = CancellationPage( owner=self.user, overrides=self.event, except_date=dt.date(1989, 2, 1), cancellation_title="Meeting Cancelled", cancellation_details="Cancelled due to lack of interest") self.event.add_child(instance=self.cancellation) self.cancellation.save_revision().publish() @timezone.override("Australia/Sydney") @freeze_timetz("1989-02-02T06:00:00+11:00") def testCurrentLocalDt(self): when = self.cancellation._current_datetime_from self.assertEqual(when.tzinfo.zone, "Australia/Sydney") self.assertEqual(when.time(), dt.time(5, 30)) self.assertEqual(when.date(), dt.date(1989, 2, 2)) @timezone.override("Australia/Sydney") @freeze_timetz("1989-02-02T06:00:00+11:00") def testFutureLocalDt(self): when = self.cancellation._future_datetime_from self.assertIsNone(when) @timezone.override("Australia/Sydney") def testPastLocalDt(self): when = self.cancellation._past_datetime_from self.assertEqual(when.tzinfo.zone, "Australia/Sydney") self.assertEqual(when.time(), dt.time(5, 30)) self.assertEqual(when.date(), dt.date(1989, 2, 2)) @timezone.override("Australia/Sydney") @freeze_timetz("1989-10-01T21:00:00+11:00") def testCopyFieldsFromParent(self): self.assertEqual(self.event.next_date, dt.date(1989, 10, 3)) cancellation = CancellationPage(owner=self.user) cancellation._copyFieldsFromParent(self.event) self.assertEqual(cancellation.overrides, self.event) self.assertEqual(cancellation.except_date, dt.date(1989, 10, 2))
class TestMultiday(TestCase): def setUp(self): self.home = Page.objects.get(slug='home') self.user = User.objects.create_user('i', '*****@*****.**', 's3(r3t') self.calendar = CalendarPage(owner=self.user, slug="schedule", title="Schedule") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = MultidayRecurringEventPage( slug="test-session", title="Test Session", repeat=Recurrence(dtstart=dt.date(2018, 1, 8), freq=WEEKLY, byweekday=[MO], until=dt.date(2018, 4, 25)), num_days=3, time_from=dt.time(10), time_to=dt.time(12, 30)) self.calendar.add_child(instance=self.event) self.info = ExtraInfoPage(owner=self.user, overrides=self.event, except_date=dt.date(2018, 2, 12), extra_title="System Demo", extra_information="<h3>System Demo</h3>") self.event.add_child(instance=self.info) self.info.save_revision().publish() def testStatusFinished(self): self.assertEqual(self.info.status, "finished") self.assertEqual(self.info.status_text, "This event has finished.") @freeze_timetz("2018-02-13 14:00:00") def testStatusStarted(self): self.assertEqual(self.info.status, "started") self.assertEqual(self.info.status_text, "This event has started.") def testWhen(self): self.assertEqual( self.info.when, "Monday 12th of February 2018 for 3 days " "starting at 10am finishing at 12:30pm") def testAt(self): self.assertEqual(self.info.at.strip(), "10am") @freeze_timetz("2018-02-13 17:00:00") def testCurrentDt(self): self.assertEqual(self.info._current_datetime_from, datetimetz(2018, 2, 12, 10, 0)) @freeze_timetz("2018-02-13 14:00:00") def testFutureDt(self): self.assertIsNone(self.info._future_datetime_from) def testPastDt(self): self.assertEqual(self.info._past_datetime_from, datetimetz(2018, 2, 12, 10, 0))
def testMainSiteAnotherCalendar(self): calendar = CalendarPage( owner=self.user, slug="events", title="Events", ) self.main.add_child(instance=calendar) calendar.save_revision().publish() self.assertFalse(CalendarPage.can_create_at(self.main))
class TestPageForm(TestCase): Form = ExtCancellationPage.get_edit_handler().get_form_class() def setUp(self): 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.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)) self.calendar.add_child(instance=self.event) self.shutdown = ExtCancellationPage( owner=self.user, overrides=self.event, cancelled_from_date=dt.date(2020, 3, 2), cancelled_to_date=dt.date(2020, 3, 6)) self.event.add_child(instance=self.shutdown) self.shutdown.save_revision().publish() def testValid(self): page = ExtCancellationPage(owner=self.user) form = self.Form( { 'overrides': self.event, 'cancelled_from_date': "2020-03-10" }, instance=page, parent_page=self.event) self.assertTrue(form.is_valid()) # is_valid() calls full_clean() self.assertDictEqual(form.errors, {}) def testExceptionAlreadyExists(self): page = ExtCancellationPage(owner=self.user) form = self.Form( { 'overrides': self.event, 'cancelled_from_date': "2020-03-02" }, instance=page, parent_page=self.event) self.assertFalse(form.is_valid()) self.assertDictEqual( form.errors, { 'cancelled_from_date': ['There is already an extended cancellation for then'] })
def setUp(self): self.user = User.objects.create_superuser('i', '*****@*****.**', 's3(r3t') self.request = RequestFactory().get("/test") self.request.user = self.user self.request.session = {} self.home = Page.objects.get(slug='home') self.page = CalendarPage(owner=self.user, slug="events", title="Events") self.home.add_child(instance=self.page) self.page.save_revision().publish()
def setUp(self): site = Site.objects.get(is_default_site=True) site.hostname = "joy.test" site.save() self.home = getPage("/home/") self.user = User.objects.create_user('i', '*****@*****.**', 's3cr3t') self.requestFactory = RequestFactory() self.calendar = CalendarPage(owner=self.user, slug="events", title="Events") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish()
def setUp(self): site = Site.objects.get(is_default_site=True) site.hostname = "joy.test" site.save() self.home = getPage("/home/") self.user = User.objects.create_user('i', '*****@*****.**', 's3cr3t') self.requestFactory = RequestFactory() self.calendar = CalendarPage(owner = self.user, slug = "events", title = "Events") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() event = SimpleEventPage(owner = self.user, slug = "mini-fair", title = "Mini-Fair", date = dt.date(2018,4,7), uid = "*****@*****.**") self.calendar.add_child(instance=event) event.save_revision().publish() event = RecurringEventPage(owner = self.user, slug = "tango-thursdays", title = "Tango Thursdays", details = "Weekly tango lessons at the Dance Spot", repeat = Recurrence(dtstart=dt.date(2018,3,29), freq=WEEKLY, byweekday=[TH]), time_from = dt.time(19,30), time_to = dt.time(22,0), tz = pytz.timezone("US/Eastern"), website = "http://torontodancespot.com/", location = "622 Bloor St. W., Toronto ON, M6G 1K7", uid = "*****@*****.**") self.calendar.add_child(instance=event) event.save_revision().publish() cancellation = CancellationPage(owner = self.user, slug = "2019-02-14-cancellation", title = "Cancellation for Thursday 14th of April", overrides = event, except_date = dt.date(2019, 2, 14)) event.add_child(instance=cancellation) cancellation.save_revision().publish() info = ExtraInfoPage(owner = self.user, slug = "2018-04-05-extra-info", title = "Extra-Info for Thursday 5th of April", overrides = event, except_date = dt.date(2018, 4, 5), extra_title = "Performance", extra_information = "Performance for the public") event.add_child(instance=info) info.save_revision().publish()
class TestPageFormDeutsche(TestCase): Form = ExtraInfoPage.get_edit_handler().get_form_class() def setUp(self): translation.activate('de') self.home = Page.objects.get(slug='home') self.user = User.objects.create_user('i', '*****@*****.**', 's3(r3t') self.calendar = CalendarPage(owner=self.user, slug="ereignisse", title="Ereignisse") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug="meeting", title="Testen Sie Meeting", repeat=Recurrence( dtstart=dt.date(1988, 1, 1), freq=WEEKLY, byweekday=[MO, WE, FR]), time_from=dt.time(13), time_to=dt.time(15, 30)) self.calendar.add_child(instance=self.event) self.info = ExtraInfoPage(owner=self.user, overrides=self.event, except_date=dt.date(1999, 1, 5), extra_title="Freitag", extra_information="Besonderer Freitag") self.event.add_child(instance=self.info) self.info.save_revision().publish() def tearDown(self): translation.deactivate() def testExceptionAlreadyExists(self): page = ExtraInfoPage(owner=self.user) form = self.Form( { 'overrides': self.event, 'except_date': "1999-01-05", 'extra_title': "Es ist Freitag", 'extra_information': rich_text("Besonderer spezieller Freitag") }, instance=page, parent_page=self.event) self.assertFalse(form.is_valid()) self.assertDictEqual( form.errors, { 'except_date': ['Dieses Datum enthält bereits zusätzliche information'] })
def setUp(self): imgFile = get_test_image_file() imgFile.name = "people.png" self.img = Image.objects.create(title="People", file=imgFile) imgName = os.path.splitext(os.path.basename(self.img.file.name))[0] self.rendName = "{}.width-350.format-png.png".format(imgName) Site.objects.update(hostname="joy.test") self.home = Page.objects.get(slug='home') self.user = User.objects.create_user('i', '*****@*****.**', 's3(R3t') self.requestFactory = RequestFactory() self.calendar = CalendarPage(owner = self.user, slug = "events", title = "Events") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish()
def setUp(self): self.home = getPage("/home/") self.user = User.objects.create_superuser('i', '*****@*****.**', 's3(r3t') self.calendar = CalendarPage(owner = self.user, slug = "events", title = "Events") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug = "leaders-meeting", title = "Leaders' Meeting", repeat = Recurrence(dtstart=dt.date(2016,2,16), freq=MONTHLY, byweekday=[TU(3)]), time_from = dt.time(19), tz = "Asia/Tokyo") self.calendar.add_child(instance=self.event) self.event.save_revision().publish()
def testCalendarMixture(self): general = GeneralCalendarPage(owner=self.user, slug="events1", title="Events") self.main.add_child(instance=general) general.save_revision().publish() self.assertTrue(CalendarPage.can_create_at(self.main)) calendar = CalendarPage(owner=self.user, slug="events2", title="Events") self.main.add_child(instance=calendar) calendar.save_revision().publish() self.assertTrue(SpecificCalendarPage.can_create_at(self.main)) specific = SpecificCalendarPage(owner=self.user, slug="events3", title="Events") self.main.add_child(instance=specific) specific.save_revision().publish()
def setUp(self): site = Site.objects.get(is_default_site=True) site.hostname = "joy.test" site.save() self.home = getPage("/home/") self.user = User.objects.create_user('i', '*****@*****.**', 's3cr3t') self.requestFactory = RequestFactory() self.calendar = CalendarPage(owner=self.user, slug="events", title="Events") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() event = RecurringEventPage( owner=self.user, slug="fierce-tango-fridays", title="Fierce Tango Fridays", details="Weekly fierce tango lessons at the Dance Spot", repeat=Recurrence(dtstart=dt.date(2018, 3, 30), until=dt.date(2018, 8, 31), freq=WEEKLY, byweekday=[FR]), time_from=dt.time(19, 30), time_to=dt.time(22, 0), tz=pytz.timezone("US/Eastern"), website="http://torontodancespot.com/", location="622 Bloor St. W., Toronto ON, M6G 1K7", uid="*****@*****.**") self.calendar.add_child(instance=event) event.save_revision().publish() GROUPS = PageViewRestriction.GROUPS self.group = Group.objects.create(name="Friday Class") info = ExtraInfoPage(owner=self.user, slug="2018-08-31-extra-info", title="Extra-Info for Friday 31st of August", overrides=event, except_date=dt.date(2018, 8, 31), extra_title="Surprise", extra_information="Surprise party") event.add_child(instance=info) info.save_revision().publish() restriction = PageViewRestriction.objects.create( restriction_type=GROUPS, page=info) restriction.groups.set([self.group]) restriction.save()
class TestPageForm(TestCase): Form = ExtraInfoPage.get_edit_handler().get_form_class() def setUp(self): 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.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(slug="test-meeting", title="Test Meeting", repeat=Recurrence( dtstart=dt.date(1988, 1, 1), freq=WEEKLY, byweekday=[MO, WE, FR]), time_from=dt.time(13), time_to=dt.time(15, 30)) self.calendar.add_child(instance=self.event) self.info = ExtraInfoPage(owner=self.user, overrides=self.event, except_date=dt.date(1999, 1, 5), extra_title="Fri-day", extra_information="Special Friday") self.event.add_child(instance=self.info) self.info.save_revision().publish() def testExceptionAlreadyExists(self): page = ExtraInfoPage(owner=self.user) form = self.Form( { 'overrides': self.event, 'except_date': "1999-01-05", 'extra_title': "It's Friday", 'extra_information': rich_text("Special Special Friday") }, instance=page, parent_page=self.event) self.assertFalse(form.is_valid()) self.assertDictEqual( form.errors, {'except_date': ['That date already has extra information']})
def setUp(self): Site.objects.update(hostname="joy.test") self.user = User.objects.create_user('i', '*****@*****.**', 's3cr3t') self.calendar = CalendarPage(owner = self.user, slug = "events", title = "Events") Page.objects.get(slug='home').add_child(instance=self.calendar) self.calendar.save() self.calendar.save_revision().publish() self.event = RecurringEventPage(owner = self.user, slug = "lug-meetup", title = "Linux Users Group Meetup", repeat = Recurrence(dtstart=dt.date(2017,8,5), freq=MONTHLY, byweekday=[TU(1)]), time_from = dt.time(18,30), time_to = dt.time(20), location = "6 Mackay St, Greymouth (upstairs)") self.calendar.add_child(instance=self.event) self.event.save_revision().publish()
def setUp(self): self.home = Page.objects.get(slug='home') self.user = User.objects.create_user('i', '*****@*****.**', 's3cr3t') self.calendar = CalendarPage(owner = self.user, slug = "events", title = "Events") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = RecurringEventPage(owner = self.user, slug = "code-for-boston", title = "Code for Boston", repeat = Recurrence(dtstart=dt.date(2017,1,1), freq=WEEKLY, byweekday=[TU]), time_from = dt.time(19), time_to = dt.time(21,30), tz = pytz.timezone("US/Eastern"), location = "4th Floor, 1 Broadway, Cambridge, MA") self.calendar.add_child(instance=self.event) self.event.save_revision().publish()
def setUp(self): self.user = User.objects.create_user('i', '*****@*****.**', 's3cr3t') self.calendar = CalendarPage(owner=self.user, slug="events", title="Events") Page.objects.get(slug='home').add_child(instance=self.calendar) self.calendar.save() self.calendar.save_revision().publish() self.event = MultidayRecurringEventPage( owner=self.user, slug="ice-festival", title="Ice Festival", repeat=Recurrence(dtstart=dt.date(2000, 12, 25), until=dt.date(2020, 1, 31), freq=YEARLY, bymonth=12, byweekday=MO(4)), num_days=40) self.calendar.add_child(instance=self.event) self.event.save_revision().publish()
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 setUp(self): self.user = User.objects.create_user('i', '*****@*****.**', 's3cr3t') self.calendar = CalendarPage(owner=self.user, slug="events", title="Events") Page.objects.get(slug='home').add_child(instance=self.calendar) self.calendar.save() self.calendar.save_revision().publish() self.event = MultidayRecurringEventPage( owner=self.user, slug="team-retreat", title="Team Retreat", repeat=Recurrence(dtstart=dt.date(2000, 1, 1), freq=YEARLY, bymonth=8, byweekday=FR(1)), num_days=3, time_from=dt.time(18), time_to=dt.time(16, 30)) self.calendar.add_child(instance=self.event) self.event.save_revision().publish()
def _setUpVeterisSubsite(self): main = getPage("/home/") home = Page(slug="veteris", title="Veteris Council") main.add_child(instance=home) home.save_revision().publish() activities = Page(slug="activities", title="Veteris Calendar") home.add_child(instance=activities) activities.save_revision().publish() Site.objects.create(hostname='veteris.joy.test', root_page_id=home.id, is_default_site=False) events = CalendarPage(owner=self.user, slug="veteris-events", title="Veteris Events") home.add_child(instance=events) events.save_revision().publish() committee = RecurringEventPage(owner=self.user, slug="veteris-committee", title="Committee Meeting", repeat=Recurrence( dtstart=dt.date(1970, 1, 5), freq=MONTHLY, byweekday=[MO], until=dt.date(1978, 8, 7)), time_from=dt.time(14), time_to=dt.time(15)) events.add_child(instance=committee) committee.save_revision().publish()
def test_girotondo_month(self): child2 = Child.objects.create(first_name='ab', last_name='bc', father=self.user, care_group='P') Absence.objects.create(child_link=self.child, from_date=date(2019, 12, 17), created_by=self.user) Absence.objects.create(child_link=self.child, from_date=date(2019, 12, 18), created_by=self.user) self.home = self.home = Page.objects.get(slug='home') self.calendar = CalendarPage(owner=self.user, slug="events", title="Events") self.home.add_child(instance=self.calendar) self.calendar.save_revision().publish() self.event = SimpleEventPage(owner=self.user, slug="pet-show", title="Pet Show", category=self.closed, date=date(2019, 12, 23)) self.calendar.add_child(instance=self.event) self.event.save_revision().publish() giro_month = GirotondoMonth(2019, 12) giro_month.holidays.add(date(2019, 12, 24), 'Xmas') self.assertFalse(giro_month.is_girotondo_day(23)) self.assertFalse(giro_month.is_girotondo_day(24)) self.assertFalse(giro_month.is_girotondo_day(22)) self.assertFalse(giro_month.is_girotondo_day(21)) self.assertTrue(giro_month.is_girotondo_day(20)) self.assertEqual(giro_month.get_children_out(17, 'P'), [self.child.first_name + ' ' + self.child.last_name]) self.assertEqual(giro_month.get_children_in(17, 'P'), [child2.first_name + ' ' + child2.last_name]) self.assertEqual(giro_month.get_children_out(12, 'P'), [])
class Test40Day(TestCase): def setUp(self): self.user = User.objects.create_user('i', '*****@*****.**', 's3cr3t') self.calendar = CalendarPage(owner=self.user, slug="events", title="Events") Page.objects.get(slug='home').add_child(instance=self.calendar) self.calendar.save() self.calendar.save_revision().publish() self.event = MultidayRecurringEventPage( owner=self.user, slug="ice-festival", title="Ice Festival", repeat=Recurrence(dtstart=dt.date(2000, 12, 25), until=dt.date(2020, 1, 31), freq=YEARLY, bymonth=12, byweekday=MO(4)), num_days=40) self.calendar.add_child(instance=self.event) self.event.save_revision().publish() def testGetEventsByDay(self): events = MultidayRecurringEventPage.events.byDay( dt.date(2020, 1, 1), dt.date(2020, 1, 31)) self.assertEqual(len(events), 31) evod = events[0] self.assertEqual(evod.date, dt.date(2020, 1, 1)) self.assertEqual(len(evod.days_events), 0) self.assertEqual(len(evod.continuing_events), 1) thisEvent = evod.continuing_events[0] self.assertEqual(thisEvent.title, "Ice Festival") evod = events[10] self.assertEqual(evod.date, dt.date(2020, 1, 11)) self.assertEqual(len(evod.continuing_events), 1) thisEvent = evod.continuing_events[0] self.assertEqual(thisEvent.title, "Ice Festival") def testStatus(self): with freeze_timetz("2019-12-20 13:00:00"): self.assertEqual(self.event.status_text, "") with freeze_timetz("2020-01-02 13:00:00"): self.assertEqual(self.event.status_text, "This event has started.") with freeze_timetz("2020-02-03 17:00:00"): self.assertEqual(self.event.status_text, "These events have finished.") def testAt(self): self.assertEqual(self.event.at.strip(), "") @freeze_timetz("2035-04-03 10:00:00") def testNextDate(self): self.assertEqual(self.event.next_date, None) @freeze_timetz("2035-04-03 10:00:00") def testPrevDate(self): self.assertEqual(self.event.prev_date, dt.date(2019, 12, 23))
def _setUpNovaSubsite(self): main = getPage("/home/") home = Page(slug="nova", title="Nova Homepage") main.add_child(instance=home) home.save_revision().publish() activities = Page(slug="activities", title="Nova Activities") home.add_child(instance=activities) activities.save_revision().publish() Site.objects.create(hostname='nova.joy.test', root_page_id=home.id, is_default_site=False) events = CalendarPage(owner=self.user, slug="nova-events", title="Nova Events") home.add_child(instance=events) events.save_revision().publish() committee = RecurringEventPage(owner=self.user, slug="executive-meeting", title="Executive Committee Meeting", repeat=Recurrence(dtstart=dt.date( 1984, 8, 5), freq=WEEKLY, byweekday=[TH]), time_from=dt.time(13), time_to=dt.time(15)) events.add_child(instance=committee) committee.save_revision().publish() event = SimpleEventPage(owner=self.user, slug="rubbish-blitz", title="Rubbish Blitz", date=dt.date(1984, 9, 13), time_from=dt.time(12, 30), time_to=dt.time(17)) events.add_child(instance=event) event.save_revision().publish() cancellation = CancellationPage( owner=self.user, slug="1984-09-13-cancellation", title="Cancellation for Thursday 13th of September", overrides=committee, except_date=dt.date(1984, 9, 13), cancellation_title="Meeting Cancelled", cancellation_details="The committee will be at " "the working bee") committee.add_child(instance=cancellation) cancellation.save_revision().publish()
def setUp(self): 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.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)) self.calendar.add_child(instance=self.event) self.shutdown = ExtCancellationPage( owner=self.user, overrides=self.event, cancelled_from_date=dt.date(2020, 3, 2), cancelled_to_date=dt.date(2020, 3, 6)) self.event.add_child(instance=self.shutdown) self.shutdown.save_revision().publish()