Example #1
0
 def test_new_stateless_incident_has_stateless_event(self):
     source_incident_id = "abcknekkebrod"
     incident = Incident.objects.create(
         start_time=timezone.now(),
         end_time=None,
         source_incident_id=source_incident_id,
         source=SourceSystemFactory(),
         description=f"Incident #{source_incident_id} created for testing",
     )
     event_stateless = incident.events.filter(type=Event.Type.STATELESS)
     self.assertEqual(1, event_stateless.count())
Example #2
0
    def test_event_has_description(self):
        source_incident_id = "abcknekkebrod"
        incident = Incident.objects.create(
            start_time=timezone.now(),
            end_time=datetime_utils.INFINITY_REPR,
            source_incident_id=source_incident_id,
            source=SourceSystemFactory(),
            description=f"Incident #{source_incident_id} created for testing",
        )
        event_start = incident.events.filter(type=Event.Type.INCIDENT_START)

        self.assertTrue(event_start)
        self.assertEqual(incident.description, incident.events.get(type="STA").description)
Example #3
0
    def init_test_objects(self):
        self.source_type1 = SourceSystemTypeFactory(name="type1")
        self.source1_user = SourceUserFactory(username="******")
        self.source1 = SourceSystemFactory(name="System 1",
                                           type=self.source_type1,
                                           user=self.source1_user)

        self.user1 = AdminUserFactory(username="******")

        self.user1_rest_client = APIClient()
        self.user1_rest_client.force_authenticate(user=self.user1)

        self.source1_rest_client = APIClient()
        self.source1_rest_client.force_authenticate(user=self.source1_user)
Example #4
0
 def setUp(self):
     disconnect_signals()
     # Lock in timestamps
     self.timestamp = timezone.now()
     # We don't care about source but let's ensure it is unique
     source = SourceSystemFactory()
     self.incident1 = StatelessIncidentFactory(source=source,
                                               start_time=self.timestamp,
                                               ticket_url="")
     self.incident2 = StatefulIncidentFactory(source=source,
                                              start_time=self.timestamp,
                                              ticket_url="")
     self.incident3 = StatefulIncidentFactory(source=source,
                                              start_time=self.timestamp,
                                              ticket_url="")
     self.incident4 = StatefulIncidentFactory(source=source,
                                              start_time=self.timestamp)
     self.incident4.end_time = self.timestamp
     self.incident4.save()
Example #5
0
 def handle(self, *args, **options):
     source = options["source"]
     source_type = options.get("source_type") or "argus"
     sst = SourceSystemTypeFactory(name=source_type)
     ss = SourceSystemFactory(name=source, type=sst)
Example #6
0
 def setUp(self):
     self.source_no_base_url = SourceSystemFactory.build(base_url="")
     self.base_url = "https://someticketsystem.example.org"
     self.source_has_base_url = SourceSystemFactory.build(base_url=self.base_url)
Example #7
0
 def setUpClass(cls):
     disconnect_signals()
     source_type = SourceSystemTypeFactory()
     cls.user = SourceUserFactory()
     cls.source = SourceSystemFactory(type=source_type, user=cls.user)
Example #8
0
 def setUp(self):
     disconnect_signals()
     source_type = SourceSystemTypeFactory()
     source_user = SourceUserFactory()
     self.source = SourceSystemFactory(type=source_type, user=source_user)