def test_element_suppressor_with_time_limits(self):
        """
        Test element suppression with time constraints
        :return:
        """

        now = timezone.now()
        hour_ago = now + timedelta(hours=-1)
        two_hours_ago = now + timedelta(hours=-1)
        hour_ahead = now + timedelta(hours=1)
        two_hours_ahead = now + timedelta(hours=2)

        # with proper time constraints
        e1 = factories.EventFactory.create()
        i1 = factories.IncidentFactory.create(event=e1, element='e1foo')
        factories.ElementSuppressorFactory.create(element='e1foo', start_time=hour_ago, end_time=hour_ahead)
        S = SuppressorPipeLine()
        self.assertTrue(S.is_suppressed(incident=i1))
        self.assertTrue(S.is_element_suppressed)
        # expired time constraints
        e2 = factories.EventFactory.create()
        i2 = factories.IncidentFactory.create(event=e2, element='e2foo')
        factories.ElementSuppressorFactory.create(element='e2foo', start_time=two_hours_ago, end_time=hour_ago)
        S = SuppressorPipeLine()
        self.assertFalse(S.is_suppressed(incident=i2))
        self.assertFalse(S.is_element_suppressed)
        # with time constraints in future
        e3 = factories.EventFactory.create()
        i3 = factories.IncidentFactory.create(event=e3, element='e3foo')
        factories.ElementSuppressorFactory.create(element='e3foo', start_time=hour_ahead, end_time=two_hours_ahead)
        S = SuppressorPipeLine()
        self.assertFalse(S.is_suppressed(incident=i3))
        self.assertFalse(S.is_element_suppressed)
 def test_element_and_event_suppressor(self):
     """
     Test ElementAndEvent suppression
     :return:
     """
     e_and_e_suppressor = factories.EventAndElementSuppressorFactory(event=self.event, element="foo")
     S = SuppressorPipeLine()
     self.assertTrue(S.is_suppressed(incident=self.incident))
     self.assertTrue(S.is_element_and_event_suppressed)
 def test_element_suppressor(self):
     """
     Test element suppression
     :return:
     """
     element_suppressor = factories.ElementSuppressorFactory.create(element="foo")
     S = SuppressorPipeLine()
     self.assertTrue(S.is_suppressed(incident=self.incident))
     self.assertTrue(S.is_element_suppressed)
 def test_element_suppressor(self):
     """
     Test element suppression
     :return:
     """
     element_suppressor = factories.ElementSuppressorFactory.create(element='foo')
     S = SuppressorPipeLine()
     self.assertTrue(S.is_suppressed(incident=self.incident))
     self.assertTrue(S.is_element_suppressed)
 def test_element_and_event_suppressor(self):
     """
     Test ElementAndEvent suppression
     :return:
     """
     e_and_e_suppressor = factories.EventAndElementSuppressorFactory(event=self.event, element='foo')
     S = SuppressorPipeLine()
     self.assertTrue(S.is_suppressed(incident=self.incident))
     self.assertTrue(S.is_element_and_event_suppressed)