def test_recurrence_indexing(self): tz = pytz.timezone("Europe/Vienna") e1 = createContentInContainer( self.portal, 'plone.app.event.dx.event', title='event1', start=tz.localize(datetime(2011, 11, 11, 11, 0)), end=tz.localize(datetime(2011, 11, 11, 12, 0)), ) # When editing via behaviors, the attributes should also be available # on the context itself. IEventRecurrence(e1).recurrence = 'RRULE:FREQ=DAILY;COUNT=4' self.assertTrue(e1.recurrence == IEventRecurrence(e1).recurrence) e1.reindexObject() # get_events, no expanded occurrences result = get_events(self.portal) self.assertEqual(len(result), 1) # Get all the occurrences result = get_events(self.portal, start=tz.localize(datetime(2011, 11, 11, 11, 0)), ret_mode=base.RET_MODE_OBJECTS, expand=True) self.assertEqual(len(result), 4)
def test_recurrence_indexing(self): utc = pytz.utc self.portal.invokeFactory( 'plone.app.event.dx.event', 'event1', start=datetime(2011, 11, 11, 11, 0, tzinfo=utc), end=datetime(2011, 11, 11, 12, 0, tzinfo=utc), timezone='UTC', whole_day=False ) e1 = self.portal['event1'] e1rec = IEventRecurrence(e1) e1rec.recurrence = 'RRULE:FREQ=DAILY;COUNT=4' e1.reindexObject() # test, if the recurrence attribute is available on the context. # DRI needs that for indexing. self.assertTrue(e1.recurrence == e1rec.recurrence) # test, if the occurrences are indexed by DRI result = get_events( e1, start=datetime(2011, 11, 12, 11, 0, tzinfo=utc) ) self.assertTrue(len(result) == 1)
def test_recurrence_indexing(self): utc = pytz.utc self.portal.invokeFactory( 'plone.app.event.dx.event', 'event1', start=datetime(2011, 11, 11, 11, 0, tzinfo=utc), end=datetime(2011, 11, 11, 12, 0, tzinfo=utc), timezone='UTC', whole_day=False ) e1 = self.portal['event1'] e1rec = IEventRecurrence(e1) e1rec.recurrence = 'RRULE:FREQ=DAILY;COUNT=4' e1.reindexObject() # test, if the recurrence attribute is available on the context. # DRI needs that for indexing. self.assertTrue(e1.recurrence == e1rec.recurrence) # test, if the occurrences are indexed by DRI result = get_events( e1, start=datetime(2011, 11, 12, 11, 0, tzinfo=utc) ) self.assertTrue(len(result) == 1) self.portal.manage_delObjects(['event1'])
def test_get_dates(self): utc = pytz.utc start = datetime(2001, 1, 1, 10, 0, tzinfo=utc) end = datetime(2001, 1, 1, 11, 0, tzinfo=utc) event = createEvent(self.folder, '1', start, end) index = event_dates(event)() self.assertEqual(len(index), 1) self.assertEqual(index[0], date(2001, 1, 1)) event = createEvent(self.folder, '2', start, end) event_rec = IEventRecurrence(event) event_rec.recurrence = 'RRULE:FREQ=DAILY;COUNT=4' event.reindexObject() index = event_dates(event)() self.assertEqual(len(index), 4) self.assertTrue(same(index, (date(2001, 1, 1), date(2001, 1, 2), date(2001, 1, 3), date(2001, 1, 4))))
def inject_sane_dates(self): """ Takes the IEventSubmissionDate data and makes nice IEventBasic data out of it. """ basic = IEventBasic(self.context) recurring = IEventRecurrence(self.context) (basic.start, basic.end, basic.whole_day, recurring.recurrence) = get_event_dates_from_submission( self.data, basic.timezone) self.submission_recurrence = recurring.recurrence