def test_json_results(self): """json events returns only the agenda items within the range""" with self.layer.get_browser() as browser: self.assertEqual( browser.open( '/root/agenda/++rest++silva.app.news.events', form={'start': datetime(2010, 9, 1).strftime("%s"), 'end': datetime(2010, 9, 30).strftime("%s")}), 200) data = json.loads(browser.contents) data.sort(key=operator.itemgetter('title')) # Hunting is not in the corresponding timezone. self.assertEqual( data, [{u'allDay': False, u'className': u'fullcalendar-agenda-item', u'end': 1283592000, u'id': u'agenda-item-%s-0' % get_identifier( self.root.events.culture.get_viewable()), u'start': 1283588400, u'title': u'Cultural event', u'url': u'http://localhost/root/events/culture'}, {u'allDay': False, u'className': u'fullcalendar-agenda-item', u'end': 1284193200, u'id': u'agenda-item-%s-0' % get_identifier( self.root.events.fishing.get_viewable()), u'start': 1284106800, u'title': u'Fishing event', u'url': u'http://localhost/root/events/fishing'}])
def test_ics(self): events = self.root.source with self.layer.get_browser() as browser: self.assertEqual(browser.open('/root/agenda/calendar.ics'), 200) self.assertEqual( browser.content_type, 'text/calendar;charset=utf-8') self.assertMultiLineEqual( browser.contents.replace("\r\n", "\n"), u"""BEGIN:VCALENDAR PRODID:-//Infrae SilvaNews Calendaring//NONSGML Calendar//EN VERSION:2.0 X-WR-CALNAME:Agenda X-WR-TIMEZONE:Europe/Amsterdam BEGIN:VEVENT CREATED:%(sunday_created)s DTEND;VALUE=DATE:%(year)s0612 DTSTART;VALUE=DATE:%(year)s0610 LAST-MODIFIED:%(sunday_modified)s SUMMARY:Sunday pépère héhé! UID:%(sunday_id)s@0@silvanews URL:http://localhost/root/source/sunday END:VEVENT BEGIN:VEVENT CREATED:%(saturday_created)s DTEND:%(year)s0604T092000Z DTSTART:%(year)s0604T082000Z LAST-MODIFIED:%(saturday_modified)s SUMMARY:Saturday “π” aka Disco UID:%(saturday_id)s@0@silvanews URL:http://localhost/root/source/saturday END:VEVENT END:VCALENDAR """ % {'year': self.year, 'sunday_id': get_identifier(events.sunday.get_viewable()), 'sunday_created': format_date(events.sunday.get_creation_datetime()), 'sunday_modified': format_date(events.sunday.get_modification_datetime()), 'saturday_id': get_identifier(events.saturday.get_viewable()), 'saturday_created': format_date(events.saturday.get_creation_datetime()), 'saturday_modified': format_date(events.saturday.get_modification_datetime()) })
def test_ics(self): with self.layer.get_browser(public_settings) as browser: self.assertEqual(browser.open('/root/testing/event.ics'), 200) self.assertEqual( browser.content_type, 'text/calendar;charset=utf-8') self.assertMultiLineEqual( browser.contents.replace("\r\n", "\n"), u"""BEGIN:VCALENDAR PRODID:-//Silva News Calendaring//lonely event// VERSION:2.0 BEGIN:VEVENT CREATED:%(created)s DTEND:20120731T160000Z DTSTART:20120731T080000Z LAST-MODIFIED:%(modified)s SUMMARY:Test aléatoire UID:%(identifier)s@0@silvanews URL:http://localhost/root/testing END:VEVENT END:VCALENDAR """ % {'identifier': get_identifier(self.root.testing.get_viewable()), 'created': format_date(self.root.testing.get_creation_datetime()), 'modified': format_date(self.root.testing.get_modification_datetime())})