示例#1
0
    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)
示例#2
0
    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)
示例#3
0
 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
示例#4
0
文件: test_sn.py 项目: Gandi/baobab
 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
示例#5
0
 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)
示例#6
0
文件: test_rss.py 项目: Gandi/baobab
 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)
示例#7
0
 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')
示例#8
0
文件: test_rss.py 项目: Gandi/baobab
 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
示例#10
0
 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')
示例#11
0
文件: test_rss.py 项目: Gandi/baobab
 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')