Exemple #1
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
Exemple #2
0
 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
Exemple #3
0
    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)
Exemple #4
0
 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')
Exemple #5
0
    def _create_event(self, duration, services, category):
        event = Event()
        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 _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
Exemple #7
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)
Exemple #8
0
 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)
Exemple #9
0
 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')
Exemple #10
0
 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)
Exemple #11
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')
Exemple #12
0
 def test_02_create_without_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 = Event.objects.get(title='My Title')
     self.assertEqual(event.date_start, now)
     self.assertEqual(event.date_end, None)
     self.assertEqual(event.duration, 10)
     self.assertEqual(event.estimate_date_end, end)
Exemple #13
0
 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')
Exemple #14
0
    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
Exemple #15
0
 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)
Exemple #16
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)
Exemple #17
0
 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')
Exemple #18
0
 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))
Exemple #19
0
    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
Exemple #20
0
 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())
Exemple #21
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')
Exemple #22
0
 def test_02_create_without_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 = Event.objects.get(title='My Title')
     self.assertEqual(event.date_start, now)
     self.assertEqual(event.date_end, None)
     self.assertEqual(event.duration, 10)
     self.assertEqual(event.estimate_date_end, end)
Exemple #23
0
    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
Exemple #24
0
 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))
Exemple #25
0
 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())
Exemple #26
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')
Exemple #27
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')