Пример #1
0
 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()
Пример #2
0
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))
Пример #3
0
 def testWhenEver(self):
     event = RecurringEventPage(slug="XYZ",
                                title="Xylophone yacht zombies",
                                repeat=Recurrence(dtstart=dt.date(
                                    1989, 1, 1),
                                                  freq=WEEKLY,
                                                  byweekday=[FR]),
                                time_from=dt.time(19))
     self.calendar.add_child(instance=event)
     cancellation = CancellationPage(owner=self.user,
                                     overrides=event,
                                     except_date=dt.date(1989, 3, 10),
                                     cancellation_title="Cancelled")
     event.add_child(instance=cancellation)
     cancellation.save_revision().publish()
     self.assertEqual(cancellation.when, "Friday 10th of March 1989 at 7pm")
Пример #4
0
 def testNeverOccursOn(self):
     cancellation = CancellationPage(owner=self.user,
                                     overrides=self.event,
                                     except_date=dt.date(1989, 2, 7),
                                     cancellation_title="Tuesday",
                                     cancellation_details="Banner")
     self.event.add_child(instance=cancellation)
     self.assertIsNone(cancellation._current_datetime_from)
     self.assertIsNone(cancellation._future_datetime_from)
     self.assertIsNone(cancellation._past_datetime_from)
Пример #5
0
 def _cancel_1999_02_08(self):
     cancellation = CancellationPage(
         owner=self.user,
         overrides=self.event,
         except_date=dt.date(1999, 2, 8),
         cancellation_title="Restructure Pending",
         cancellation_details="Keep it quiet")
     self.event.add_child(instance=cancellation)
     PASSWORD = PageViewRestriction.PASSWORD
     restriction = PageViewRestriction.objects.create(
         restriction_type=PASSWORD, password="******", page=cancellation)
     restriction.save()
     return restriction
Пример #6
0
 def testStatus(self):
     self.assertEqual(self.cancellation.status, "cancelled")
     self.assertEqual(self.cancellation.status_text,
                      "This event has been cancelled.")
     now = dt.datetime.now()
     myday = now.date() + dt.timedelta(1)
     friday = myday + dt.timedelta(days=(4 - myday.weekday()) % 7)
     futureCan = CancellationPage(owner=self.user,
                                  overrides=self.event,
                                  except_date=friday,
                                  cancellation_title="",
                                  cancellation_details="")
     self.event.add_child(instance=futureCan)
     self.assertEqual(futureCan.status, "cancelled")
     self.assertEqual(futureCan.status_text,
                      "This event has been cancelled.")
Пример #7
0
 def testGetEventsByDay(self):
     hiddenCancellation = CancellationPage(owner=self.user,
                                           overrides=self.event,
                                           except_date=dt.date(1989, 2, 13))
     self.event.add_child(instance=hiddenCancellation)
     events = RecurringEventPage.events.byDay(dt.date(1989, 2, 1),
                                              dt.date(1989, 2, 28))
     self.assertEqual(len(events), 28)
     evod1 = events[0]
     self.assertEqual(evod1.date, dt.date(1989, 2, 1))
     self.assertEqual(len(evod1.days_events), 1)
     self.assertEqual(len(evod1.continuing_events), 0)
     title, page, url = evod1.days_events[0]
     self.assertEqual(title, "Meeting Cancelled")
     self.assertIs(type(page), CancellationPage)
     evod2 = events[12]
     self.assertEqual(evod2.date, dt.date(1989, 2, 13))
     self.assertEqual(len(evod2.days_events), 0)
     self.assertEqual(len(evod2.continuing_events), 0)
 def testLastOccurenceCancelledStatus(self):
     event = RecurringEventPage(owner=self.user,
                                slug="breakfast2",
                                title="Breakfast-in-bed",
                                repeat=Recurrence(dtstart=dt.date(
                                    2008, 2, 1),
                                                  until=dt.date(2008, 5, 9),
                                                  freq=WEEKLY,
                                                  byweekday=[SA, SU]),
                                time_from=dt.time(8),
                                time_to=dt.time(9))
     self.calendar.add_child(instance=event)
     cancellation = CancellationPage(
         owner=self.user,
         overrides=event,
         except_date=dt.date(2008, 5, 4),
         cancellation_title="Fire in the kitchen",
         cancellation_details="The bacon fat is burning")
     event.add_child(instance=cancellation)
     self.assertEqual(event.status, "finished")
Пример #9
0
    def setUp(self):
        self.home = Page.objects.get(slug='home')
        self.user = User.objects.create_user('i', '*****@*****.**', 's3cr3t')
        self.request = RequestFactory().get("/test")
        self.request.user = self.user
        self.request.session = {}
        self.calendar = GeneralCalendarPage(owner=self.user,
                                            slug="events",
                                            title="Events")
        self.home.add_child(instance=self.calendar)
        self.group = GroupPage(slug="initech", title="Initech Corporation")
        self.home.add_child(instance=self.group)

        self.show = SimpleEventPage(owner=self.user,
                                    slug="pet-show",
                                    title="Pet Show",
                                    date=dt.date(2013, 1, 5),
                                    time_from=dt.time(11),
                                    time_to=dt.time(17, 30),
                                    uid="29daefed-fed1-4e47-9408-43ec9b06a06d")
        self.calendar.add_child(instance=self.show)

        GROUPS = PageViewRestriction.GROUPS
        self.friends = Group.objects.create(name="Friends")
        self.rendezvous = SimpleEventPage(
            owner=self.user,
            slug="rendezvous",
            title="Private Rendezvous",
            date=dt.date(2013, 1, 10),
            uid="80af64e7-84e6-40d9-8b4f-7edf92aab9f7")
        self.calendar.add_child(instance=self.rendezvous)
        self.rendezvous.save_revision().publish()
        restriction = PageViewRestriction.objects.create(
            restriction_type=GROUPS, page=self.rendezvous)
        restriction.groups.set([self.friends])
        restriction.save()

        self.party = MultidayEventPage(owner=self.user,
                                       slug="allnighter",
                                       title="All Night",
                                       date_from=dt.date(2012, 12, 31),
                                       date_to=dt.date(2013, 1, 1),
                                       time_from=dt.time(23),
                                       time_to=dt.time(3),
                                       uid="initiative+technology")
        self.calendar.add_child(instance=self.party)

        self.standup = RecurringEventPage(slug="test-meeting",
                                          title="Test Meeting",
                                          repeat=Recurrence(
                                              dtstart=dt.date(2013, 1, 1),
                                              until=dt.date(2013, 5, 31),
                                              freq=WEEKLY,
                                              byweekday=[MO, WE, FR]),
                                          time_from=dt.time(13, 30),
                                          time_to=dt.time(16),
                                          uid="initiative+technology")
        self.group.add_child(instance=self.standup)

        self.postponement = PostponementPage(
            owner=self.user,
            slug="2013-01-09-postponement",
            title="Postponement for Wednesday 16th of October",
            overrides=self.standup,
            except_date=dt.date(2013, 1, 16),
            cancellation_title="Meeting Postponed",
            cancellation_details=
            "The meeting has been postponed until tomorrow",
            postponement_title="A Meeting",
            date=dt.date(2013, 1, 17),
            time_from=dt.time(13),
            time_to=dt.time(16, 30),
            details="Yes a test meeting on a Thursday")
        self.standup.add_child(instance=self.postponement)

        cancelTuesday = CancellationPage(
            owner=self.user,
            slug="2013-01-01-cancellation",
            title="CancellationPage for Tuesday 1st of January",
            overrides=self.standup,
            except_date=dt.date(2013, 1, 1),
            cancellation_title="Meeting Cancelled")
        self.standup.add_child(instance=cancelTuesday)
Пример #10
0
class Test(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),
                                        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 testGetEventsByDay(self):
        hiddenCancellation = CancellationPage(owner=self.user,
                                              overrides=self.event,
                                              except_date=dt.date(1989, 2, 13))
        self.event.add_child(instance=hiddenCancellation)
        events = RecurringEventPage.events.byDay(dt.date(1989, 2, 1),
                                                 dt.date(1989, 2, 28))
        self.assertEqual(len(events), 28)
        evod1 = events[0]
        self.assertEqual(evod1.date, dt.date(1989, 2, 1))
        self.assertEqual(len(evod1.days_events), 1)
        self.assertEqual(len(evod1.continuing_events), 0)
        title, page, url = evod1.days_events[0]
        self.assertEqual(title, "Meeting Cancelled")
        self.assertIs(type(page), CancellationPage)
        evod2 = events[12]
        self.assertEqual(evod2.date, dt.date(1989, 2, 13))
        self.assertEqual(len(evod2.days_events), 0)
        self.assertEqual(len(evod2.continuing_events), 0)

    def testOccursOn(self):
        self.assertIs(self.event._occursOn(dt.date(1989, 2, 1)), False)
        self.assertIs(self.event._occursOn(dt.date(1989, 2, 3)), True)

    def testUnexplainedCancellation(self):
        self._cancel_1999_02_08()

        events = RecurringEventPage.events.byDay(dt.date(1999, 2, 1),
                                                 dt.date(1999, 2, 28))
        self.assertEqual(len(events), 28)
        evod = events[7]
        self.assertEqual(evod.date, dt.date(1999, 2, 8))
        self.assertEqual(len(evod.days_events), 0)
        self.assertEqual(len(evod.continuing_events), 0)

    def testUnexplainedCancellationExplained(self):
        restriction = self._cancel_1999_02_08()

        request = RequestFactory().get("/test")
        request.user = self.user
        KEY = PageViewRestriction.passed_view_restrictions_session_key
        request.session = {KEY: [restriction.id]}
        events = RecurringEventPage.events(request).byDay(
            dt.date(1999, 2, 1), dt.date(1999, 2, 28))
        self.assertEqual(len(events), 28)
        evod = events[7]
        self.assertEqual(evod.date, dt.date(1999, 2, 8))
        self.assertEqual(len(evod.days_events), 1)
        self.assertEqual(len(evod.continuing_events), 0)
        title, page, url = evod.days_events[0]
        self.assertEqual(title, "Restructure Pending")
        self.assertIs(type(page), CancellationPage)

    def _cancel_1999_02_08(self):
        cancellation = CancellationPage(
            owner=self.user,
            overrides=self.event,
            except_date=dt.date(1999, 2, 8),
            cancellation_title="Restructure Pending",
            cancellation_details="Keep it quiet")
        self.event.add_child(instance=cancellation)
        PASSWORD = PageViewRestriction.PASSWORD
        restriction = PageViewRestriction.objects.create(
            restriction_type=PASSWORD, password="******", page=cancellation)
        restriction.save()
        return restriction

    def testStatus(self):
        self.assertEqual(self.cancellation.status, "cancelled")
        self.assertEqual(self.cancellation.status_text,
                         "This event has been cancelled.")
        now = dt.datetime.now()
        myday = now.date() + dt.timedelta(1)
        friday = myday + dt.timedelta(days=(4 - myday.weekday()) % 7)
        futureCan = CancellationPage(owner=self.user,
                                     overrides=self.event,
                                     except_date=friday,
                                     cancellation_title="",
                                     cancellation_details="")
        self.event.add_child(instance=futureCan)
        self.assertEqual(futureCan.status, "cancelled")
        self.assertEqual(futureCan.status_text,
                         "This event has been cancelled.")

    def testWhen(self):
        self.assertEqual(self.cancellation.when,
                         "Wednesday 1st of February 1989 at 1pm to 3:30pm")

    def testWhenEver(self):
        event = RecurringEventPage(slug="XYZ",
                                   title="Xylophone yacht zombies",
                                   repeat=Recurrence(dtstart=dt.date(
                                       1989, 1, 1),
                                                     freq=WEEKLY,
                                                     byweekday=[FR]),
                                   time_from=dt.time(19))
        self.calendar.add_child(instance=event)
        cancellation = CancellationPage(owner=self.user,
                                        overrides=event,
                                        except_date=dt.date(1989, 3, 10),
                                        cancellation_title="Cancelled")
        event.add_child(instance=cancellation)
        cancellation.save_revision().publish()
        self.assertEqual(cancellation.when, "Friday 10th of March 1989 at 7pm")

    def testAt(self):
        self.assertEqual(self.cancellation.at.strip(), "1pm")

    def testCurrentDt(self):
        self.assertIsNone(self.cancellation._current_datetime_from)

    def testFutureDt(self):
        self.assertIsNone(self.cancellation._future_datetime_from)

    def testPastDt(self):
        self.assertEqual(self.cancellation._past_datetime_from,
                         datetimetz(1989, 2, 1, 13, 0))

    def testNeverOccursOn(self):
        cancellation = CancellationPage(owner=self.user,
                                        overrides=self.event,
                                        except_date=dt.date(1989, 2, 7),
                                        cancellation_title="Tuesday",
                                        cancellation_details="Banner")
        self.event.add_child(instance=cancellation)
        self.assertIsNone(cancellation._current_datetime_from)
        self.assertIsNone(cancellation._future_datetime_from)
        self.assertIsNone(cancellation._past_datetime_from)

    def testGroup(self):
        self.assertIsNone(self.cancellation.group)

    def testOverridesRepeat(self):
        self.assertEqual(self.cancellation.overrides_repeat, self.event.repeat)

    def testGetContext(self):
        request = RequestFactory().get("/test")
        context = self.cancellation.get_context(request)
        self.assertIn('overrides', context)
Пример #11
0
class Test(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),
                                        time_to=dt.time(15, 30))
        self.calendar.add_child(instance=self.event)
        self.cancellation = CancellationPage(
            owner=self.user,
            slug="1989-02-01-cancellation",
            title="Cancellation for Wednesday 1st of February",
            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 testGetEventsByDay(self):
        hiddenCancellation = CancellationPage(
            owner=self.user,
            slug="1989-02-13-cancellation",
            title="Cancellation for Monday 13th of February",
            overrides=self.event,
            except_date=dt.date(1989, 2, 13))
        self.event.add_child(instance=hiddenCancellation)
        events = RecurringEventPage.events.byDay(dt.date(1989, 2, 1),
                                                 dt.date(1989, 2, 28))
        self.assertEqual(len(events), 28)
        evod1 = events[0]
        self.assertEqual(evod1.date, dt.date(1989, 2, 1))
        self.assertEqual(len(evod1.days_events), 1)
        self.assertEqual(len(evod1.continuing_events), 0)
        title, page, url = evod1.days_events[0]
        self.assertEqual(title, "Meeting Cancelled")
        self.assertIs(type(page), CancellationPage)
        evod2 = events[12]
        self.assertEqual(evod2.date, dt.date(1989, 2, 13))
        self.assertEqual(len(evod2.days_events), 0)
        self.assertEqual(len(evod2.continuing_events), 0)

    def testUnexplainedCancellation(self):
        self._cancel_1999_02_08()

        events = RecurringEventPage.events.byDay(dt.date(1999, 2, 1),
                                                 dt.date(1999, 2, 28))
        self.assertEqual(len(events), 28)
        evod = events[7]
        self.assertEqual(evod.date, dt.date(1999, 2, 8))
        self.assertEqual(len(evod.days_events), 0)
        self.assertEqual(len(evod.continuing_events), 0)

    def testUnexplainedCancellationExplained(self):
        restriction = self._cancel_1999_02_08()

        request = RequestFactory().get("/test")
        request.user = self.user
        KEY = PageViewRestriction.passed_view_restrictions_session_key
        request.session = {KEY: [restriction.id]}
        events = RecurringEventPage.events(request).byDay(
            dt.date(1999, 2, 1), dt.date(1999, 2, 28))
        self.assertEqual(len(events), 28)
        evod = events[7]
        self.assertEqual(evod.date, dt.date(1999, 2, 8))
        self.assertEqual(len(evod.days_events), 1)
        self.assertEqual(len(evod.continuing_events), 0)
        title, page, url = evod.days_events[0]
        self.assertEqual(title, "Restructure Pending")
        self.assertIs(type(page), CancellationPage)

    def _cancel_1999_02_08(self):
        cancellation = CancellationPage(
            owner=self.user,
            slug="1999-02-08-cancellation",
            title="Cancellation for Monday 8th of February",
            overrides=self.event,
            except_date=dt.date(1999, 2, 8),
            cancellation_title="Restructure Pending",
            cancellation_details="Keep it quiet")
        self.event.add_child(instance=cancellation)
        PASSWORD = PageViewRestriction.PASSWORD
        restriction = PageViewRestriction.objects.create(
            restriction_type=PASSWORD, password="******", page=cancellation)
        restriction.save()
        return restriction

    def testStatus(self):
        self.assertEqual(self.cancellation.status, "cancelled")
        self.assertEqual(self.cancellation.status_text,
                         "This event has been cancelled.")
        now = dt.datetime.now()
        myday = now.date() + dt.timedelta(1)
        friday = myday + dt.timedelta(days=(4 - myday.weekday()) % 7)
        futureCan = CancellationPage(owner=self.user,
                                     slug="fri-cancellation",
                                     title="Cancellation for Friday",
                                     overrides=self.event,
                                     except_date=friday,
                                     cancellation_title="",
                                     cancellation_details="")
        self.event.add_child(instance=futureCan)
        self.assertEqual(futureCan.status, "cancelled")
        self.assertEqual(futureCan.status_text,
                         "This event has been cancelled.")

    def testWhen(self):
        self.assertEqual(self.cancellation.when,
                         "Wednesday 1st of February 1989 at 1pm to 3:30pm")

    def testAt(self):
        self.assertEqual(self.cancellation.at.strip(), "1pm")
Пример #12
0
class TestCancellation(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),
                                        time_to=dt.time(15, 30))
        self.calendar.add_child(instance=self.event)
        self.cancellation = CancellationPage(
            owner=self.user,
            slug="1989-02-01-cancellation",
            title="Cancellation for Wednesday 1st of February",
            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 testGetEventsByDay(self):
        hiddenCancellation = CancellationPage(
            owner=self.user,
            slug="1989-02-13-cancellation",
            title="Cancellation for Monday 13th of February",
            overrides=self.event,
            except_date=dt.date(1989, 2, 13))
        self.event.add_child(instance=hiddenCancellation)
        events = RecurringEventPage.events.byDay(dt.date(1989, 2, 1),
                                                 dt.date(1989, 2, 28))
        self.assertEqual(len(events), 28)
        evod1 = events[0]
        self.assertEqual(evod1.date, dt.date(1989, 2, 1))
        self.assertEqual(len(evod1.days_events), 1)
        self.assertEqual(len(evod1.continuing_events), 0)
        title, page = evod1.days_events[0]
        self.assertEqual(title, "Meeting Cancelled")
        self.assertIs(type(page), CancellationPage)
        evod2 = events[12]
        self.assertEqual(evod2.date, dt.date(1989, 2, 13))
        self.assertEqual(len(evod2.days_events), 0)
        self.assertEqual(len(evod2.continuing_events), 0)

    def testStatus(self):
        self.assertEqual(self.cancellation.status, "cancelled")
        self.assertEqual(self.cancellation.status_text,
                         "This event has been cancelled.")
        now = dt.datetime.now()
        myday = now.date() + dt.timedelta(1)
        friday = myday + dt.timedelta(days=(4 - myday.weekday()) % 7)
        futureCan = CancellationPage(owner=self.user,
                                     slug="fri-cancellation",
                                     title="Cancellation for Friday",
                                     overrides=self.event,
                                     except_date=friday,
                                     cancellation_title="",
                                     cancellation_details="")
        self.event.add_child(instance=futureCan)
        self.assertEqual(futureCan.status, "cancelled")
        self.assertEqual(futureCan.status_text,
                         "This event has been cancelled.")

    def testWhen(self):
        self.assertEqual(self.cancellation.when,
                         "Wednesday 1st of February 1989 at 1pm to 3:30pm")

    def testAt(self):
        self.assertEqual(self.cancellation.at.strip(), "1pm")
Пример #13
0
 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))