def test_06_postpone_with_date_end(self): event = Event() now = tz_now().replace(microsecond=0) end = now + datetime.timedelta(minutes=10) event.date_start = now event.duration = 10 event.title = 'My Title' event.summary = '' event.category = 1 event.save() event.date_end = end event.save() event = Event.objects.get(title='My Title') self.assertEqual(event.date_start, now) self.assertEqual(event.date_end, end) self.assertEqual(event.estimate_date_end, end) self.assertEqual(event.duration, 10) event.date_start = end event.date_end = event.date_start + datetime.timedelta(minutes=12) event.save() event = Event.objects.get(title='My Title') self.assertEqual(event.date_start, end) self.assertEqual(event.date_end, end + datetime.timedelta(minutes=12)) self.assertEqual(event.estimate_date_end, event.date_end) self.assertEqual(event.duration, 12)
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 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 test_04_title_event_incident(self): """ Test if the event have no tag [STARTED] if it's an incident """ event = Event() event.date_start = tz_now() - datetime.timedelta(minutes=10) event.duration = 120 event.title = 'My Title' event.summary = '' event.category = event.INCIDENT event.save() event = Event.objects.all()[0] title = self.rss.item_title(event) self.assertEqual(title, 'My Title')
def _create_event(self, now, end=None): event = Event() event.date_start = now if not end: event.duration = 42 event.date_end = end event.title = 'My Title' event.summary = '' event.category = Event.INCIDENT event.msg = 'a msg to publish' event.save() SnEvent.objects.all().delete() return event
def test_02_event_planed_but_not_started(self): """ Test if the event have not tag [] at the beginning of the title """ event = Event() event.date_start = tz_now() + datetime.timedelta(days=3) event.duration = 120 event.title = 'My Title' event.summary = '' event.category = 1 event.save() event = Event.objects.all()[0] title = self.rss.item_title(event) self.assertEqual(title, 'My Title')
def test_07_item_link_without_eventlogs(self): """ Test if the item link is formated correctly """ 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] link = self.rss.item_link(event) self.assertEqual(link, '/timeline/events/%d' % event.id)
def _create_event(self, duration, services, category): event = BOEvent() event.date_start = now() event.duration = duration event.title = 'My Title: %d' % duration event.summary = '' event.category = category event.save() event.services.add(*services) def _end_event(event=event): event.date_end = now() event.save() event.end = _end_event return event
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())
def _create_event(self, duration, services, category): event = BOEvent() event.date_start = now() event.duration = duration event.title = 'My Title: %d' % duration event.summary = '' event.category = category event.save() event.services.add(*services) EventData.objects.create(event=event, lang_id=1, title=event.title, user_id=1) def _end_event(event=event): event.date_end = now() event.save() event.end = _end_event return event
def test_03_title_event_maintenance_is_started(self): """ Test if the event have been started and if the title is set correctly with the tag [STARTED] """ event = Event() event.date_start = tz_now() - datetime.timedelta(minutes=10) event.duration = 120 event.title = 'My Title' event.summary = '' event.category = event.MAINTENANCE event.save() event = Event.objects.all()[0] title = self.rss.item_title(event) self.assertEqual(title, '[STARTED] My Title') event.date_end = tz_now() + datetime.timedelta(minutes=20) event.save() title = self.rss.item_title(event) self.assertEqual(title, '[STARTED] My Title')
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())