def test_01_rss_order(self): """ Test if the RSS feed is generated with the good order (pubdate by desc) """ def getKey(last_update): return last_update event = Event() order_expected = sorted( [event.last_update for event in Event.objects.all()[:50]], key=getKey, reverse=True) items_order = [event.last_update for event in self.rss.items()] self.assertListEqual(items_order, order_expected) event.date_start = tz_now() + datetime.timedelta(minutes=10) event.duration = 120 event.category = event.MAINTENANCE event.summary = '' event.save() order_expected = sorted( [event.last_update for event in Event.objects.all()[:50]], key=getKey, reverse=True) items_order = [event.last_update for event in self.rss.items()] self.assertListEqual(items_order, order_expected) eventlog = EventLog(event=event, comment='', user_id=1) eventlog.save() order_expected = sorted( [event.last_update for event in Event.objects.all()[:50]], key=getKey, reverse=True) items_order = [event.last_update for event in self.rss.items()] self.assertListEqual(items_order, order_expected)
def _create_eventlog(self, now, end, category): event = Event() event.date_start = now event.date_end = end event.title = 'My Title' event.summary = '' event.category = category event.msg = None # to not trigger the event on_event event.save() eventlog = EventLog() eventlog.user_id = 1 eventlog.event = event eventlog.comment = '' eventlog.msg = 'a eventlog msg' eventlog.save() return eventlog
def test_08_item_link_with_eventlogs(self): """ Due to cache client, the link should be updated when a new eventlogs is added on an event """ event = Event() event.date_start = tz_now() event.duration = 120 event.title = 'My title' event.summary = '' event.category = event.INCIDENT event.save() eventlog = EventLog(event=event, comment='Comment', user_id=1) eventlog.save() link = self.rss.item_link(event) self.assertEqual( link, '/timeline/events/%d?evnt_id=%d' % (event.id, event.eventlogs.all()[0].id))
def test_05_event_have_been_update(self): """ Test if the event have been update and if the title is set correctly with the tag [UPDATE] """ event = Event() event.date_start = tz_now() event.duration = 120 event.title = 'My Title' event.summary = '' event.category = event.INCIDENT event.save() event = Event.objects.all()[0] eventlog = EventLog(event=event, comment='Comment', user_id=1) eventlog.save() title = self.rss.item_title(event) self.assertEqual(title, '[UPDATE %d] My Title' % event.eventlogs.count())