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 _create_event(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 = 'a msg to publish' event.save() return event
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_10_item_link_without_eventlogs_but_end_date(self): """ Due to cache client, the link should be updated when the date end is set event if there is no event log """ event = Event() event.date_start = tz_now() - datetime.timedelta(minutes=20) event.date_end = event.date_start + datetime.timedelta(minutes=15) event.title = 'My title' event.summary = '' event.category = event.INCIDENT event.save() link = self.rss.item_link(event) self.assertEqual(link, '/timeline/events/%d?evnt_id=1' % event.id)
def test_06_event_is_finished(self): """ Test if the event is finished and if the title is set correctly with the tag [FINISHED] """ event = Event() event.date_start = tz_now() - datetime.timedelta(minutes=20) event.date_end = tz_now() - datetime.timedelta(minutes=10) 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, '[FINISHED] My Title')
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_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')