Пример #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_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)
Пример #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)
Пример #4
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)
Пример #5
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')
Пример #6
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')
Пример #7
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
Пример #8
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')
Пример #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')
Пример #10
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)
Пример #11
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)
Пример #12
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
Пример #13
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))
Пример #14
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())
Пример #15
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
Пример #16
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')
Пример #17
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')
Пример #18
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
Пример #19
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))
Пример #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())