Ejemplo n.º 1
0
 def testGetWhen(self):
     self.assertEqual(Weekday(0)._getWhen(0), "Monday")
     self.assertEqual(FR(1)._getWhen(0), "first Friday")
     self.assertEqual(SU._getWhen(1), "Monday")
     self.assertEqual(WE._getWhen(-2), "Monday")
     self.assertEqual(FR(1)._getWhen(-1), "Thursday before the first Friday")
     self.assertEqual(SU(1)._getWhen(2), "Tuesday after the first Sunday")
Ejemplo n.º 2
0
 def test2ndAnd4thFriOffsetNeg1(self):
     rr = Recurrence(dtstart=dt.date(2009, 1, 1),
                     freq=MONTHLY,
                     byweekday=[FR(2), FR(4)])
     self.assertEqual(
         rr._getWhen(-1), "The Thursday before the second Friday and "
         "Thursday before the fourth Friday of the month")
Ejemplo n.º 3
0
 def testFromPage(self):
     page = RecurringEventPage(owner=self.user,
                               slug="lunch-and-code",
                               title="Lunch and Code",
                               details="What we'll do really depends on "
                               "what the group feels is useful, "
                               "some ideas are:\n"
                               "- Providing feedback on past, or "
                               "in progress, projects\n"
                               "- Pair programming\n"
                               "- Coding\n",
                               repeat=Recurrence(dtstart=dt.date(
                                   2017, 3, 15),
                                                 freq=MONTHLY,
                                                 byweekday=[FR(-1)]),
                               time_from=dt.time(12),
                               time_to=dt.time(13),
                               tz=pytz.timezone("Pacific/Auckland"),
                               location="70 Molesworth Street, Wellington")
     self.calendar.add_child(instance=page)
     page.save_revision().publish()
     gev = RecurringGEvent.fromPage(page)
     self.assertEqual(
         gev.url, "http://www.google.com/calendar/event?"
         "action=TEMPLATE&"
         "text=Lunch+and+Code&"
         "details=What+we%27ll+do+really+depends+on+what+the+"
         "group+feels+is+useful%2C+some+ideas+are%3A%0A"
         "-+Providing+feedback+on+past%2C+or+in+progress%2C+projects%0A"
         "-+Pair+programming%0A-+Coding%0A&"
         "location=70+Molesworth+Street%2C+Wellington&"
         "dates=20170331T120000%2F20170331T130000&"
         "ctz=Pacific%2FAuckland&"
         "recur=RRULE%3AFREQ%3DMONTHLY%3BWKST%3DSU%3BBYDAY%3D-1FR")
Ejemplo n.º 4
0
 def testServeRecurring(self):
     page = RecurringEventPage(owner=self.user,
                               slug="lunch-and-code",
                               title="Lunch and Code",
                               repeat=Recurrence(dtstart=dt.date(
                                   2017, 3, 15),
                                                 freq=MONTHLY,
                                                 byweekday=[FR(-1)]),
                               time_from=dt.time(12),
                               time_to=dt.time(13),
                               tz=pytz.timezone("Pacific/Auckland"),
                               location="70 Molesworth Street, Wellington")
     self.calendar.add_child(instance=page)
     page.save_revision().publish()
     response = self.handler.serve(
         page, self._getRequest("/events/lunch-and-code/"
                                "?format=google"))
     self.assertEqual(response.status_code, 302)
     self.assertEqual(
         response.url,
         "http://www.google.com/calendar/event?action=TEMPLATE&"
         "text=Lunch+and+Code&"
         "location=70+Molesworth+Street%2C+Wellington&"
         "dates=20170331T120000%2F20170331T130000&"
         "ctz=Pacific%2FAuckland&"
         "recur=RRULE%3AFREQ%3DMONTHLY%3BWKST%3DSU%3BBYDAY%3D-1FR")
 def testWhenEver(self):
     event = RecurringEventPage(slug="OpQ",
                                title="Orangepurple Quagga",
                                repeat=Recurrence(dtstart=dt.date(
                                    2020, 1, 1),
                                                  freq=MONTHLY,
                                                  byweekday=[FR(-1)]),
                                time_from=dt.time(19))
     self.calendar.add_child(instance=event)
     shutdown = ExtCancellationPage(owner=self.user,
                                    overrides=event,
                                    cancelled_from_date=dt.date(2020, 4, 1))
     event.add_child(instance=shutdown)
     shutdown.save_revision().publish()
     self.assertEqual(
         shutdown.when,
         "Cancelled from Wednesday 1st of April until further notice")
Ejemplo n.º 6
0
 def testShowMulidayRecurringEvent25(self):
     event = MultidayRecurringEventPage(slug      = "leaders-retreat",
                                        title     = "Leaders' Retreet",
                                        repeat    = Recurrence(dtstart=dt.date(2016,2,16),
                                                               freq=YEARLY,
                                                               bymonth=3,
                                                               byweekday=[FR(1)]),
                                        time_from = dt.time(19),
                                        num_days  = 3,
                                        tz        = "Asia/Tokyo")
     self.calendar.add_child(instance=event)
     event.save_revision().publish()
     panel = HiddenNumDaysPanel()
     panel = panel.bind_to(instance=event,
                           request=self._getRequest(),
                           form=self.form)
     content = panel.render_as_object()
     self.assertHTMLEqual(content, self.FIELD_CONTENT)
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
 def testRepr(self):
     self.assertEqual(repr(Weekday(0)), "MO")
     self.assertEqual(repr(Weekday(4,2)), "+2FR")
     self.assertEqual(repr(SA), "SA")
     self.assertEqual(repr(FR(3)), "+3FR")
     self.assertEqual(repr(WE(-2)), "-2WE")
Ejemplo n.º 9
0
 def testStr(self):
     self.assertEqual(str(Weekday(0)), "Monday")
     self.assertEqual(str(Weekday(4,1)), "first Friday")
     self.assertEqual(str(Weekday(4,-1)), "last Friday")
     self.assertEqual(str(SA), "Saturday")
     self.assertEqual(str(FR(3)), "third Friday")