def init_test_objects(self): self.source_type = SourceSystemTypeFactory(name="nav") self.source1_user = SourceUserFactory(username="******") self.source1 = SourceSystemFactory(name="NAV 1", type=self.source_type, user=self.source1_user) self.source2_user = SourceUserFactory(username="******") self.source2 = SourceSystemFactory(name="NAV 2", type=self.source_type, user=self.source2_user)
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)
def test_tags_single(self): user = SourceUserFactory() tag1 = TagFactory(key="testkey1", value="testvalue1") tag2 = TagFactory(key="testkey2", value="testvalue2") incident5 = IncidentFactory(source=self.source1) for incident in (self.incident1, self.incident2, self.incident3): IncidentTagRelation.objects.get_or_create(tag=tag1, incident=incident, added_by=user) for incident in (self.incident3, self.incident4, incident5): IncidentTagRelation.objects.get_or_create(tag=tag1, incident=incident, added_by=user) qs = Incident.objects.order_by("pk") expected = qs.from_tags(str(tag1)) result = IncidentFilter.incident_filter(qs, "tags", str(tag1)) self.assertEqual(list(expected), list(result.order_by("pk")))
def test_tags_multiple_same_key(self): user = SourceUserFactory() tag1 = TagFactory(key='testkey', value='testvalue1') tag2 = TagFactory(key='testkey', value='testvalue2') incident5 = IncidentFactory(source=self.source1) for incident in (self.incident1, self.incident2, self.incident3): IncidentTagRelation.objects.get_or_create(tag=tag1, incident=incident, added_by=user) for incident in (self.incident3, self.incident4, incident5): IncidentTagRelation.objects.get_or_create(tag=tag1, incident=incident, added_by=user) qs = Incident.objects.order_by('pk') expected = qs.from_tags(str(tag1), str(tag2)) result = IncidentFilter.incident_filter( qs, 'tags', [str(tag1), str(tag2)]) self.assertEqual(list(expected), list(result.order_by('pk')))
def setUp(self): disconnect_signals() source_type = SourceSystemTypeFactory() source_user = SourceUserFactory() self.source = SourceSystemFactory(type=source_type, user=source_user)
def setUpClass(cls): disconnect_signals() source_type = SourceSystemTypeFactory() cls.user = SourceUserFactory() cls.source = SourceSystemFactory(type=source_type, user=cls.user)