def create_cis(self): self.ci1 = CI( uid='uid-ci1', type=self.types[0], barcode='barcodeci1', name='ciname1', ) self.ci1.save() self.ci1.layers = [self.layers[0].id, self.layers[1].id] self.ci1.save() self.ci2 = CI( uid='uid-ci2', type=self.types[1], barcode='barcodeci2', name='ciname2', ) self.ci2.save() self.ci2.layers = [self.layers[0].id] self.ci2.save() self.ci3 = CI( uid='other-ci3', type=self.types[1], barcode='otherbarcodeci3', name='otherci', ) self.ci3.save() self.ci3.layers = [self.layers[1].id] self.ci3.save()
def setUp(self): self.client = login_as_su() self.service = CI(name='allegro.pl', type=CIType.objects.get(id=CI_TYPES.SERVICE)) self.service.save() self.db_service = CI.objects.get(id=self.service.id) self.venture = CI(name='allegro_prod', type=CIType.objects.get(id=CI_TYPES.VENTURE)) self.venture.save() self.ci_venture = CI.objects.get(id=self.venture.id) self.relation = CIRelation( parent=self.ci_venture, child=self.db_service, type=CI_RELATION_TYPES.CONTAINS, ) self.relation.save()
def test_reports_views(self): url = '/ui/reports/services/' report = self.client.get(url, follow=True) self.assertEqual(report.status_code, 200) invalid_relation = report.context['invalid_relation'] services_without_venture = report.context['services_without_venture'] self.assertEqual(invalid_relation[0].name, 'allegro.pl') self.assertEqual(len(invalid_relation), 1) self.assertEqual(len(services_without_venture), 0) # local service for tests service = CI(name='ceneo.pl', type=CIType.objects.get(id=CI_TYPES.SERVICE)) service.save() # local venture for tests venture = CI(name='allegro_prod', type=CIType.objects.get(id=CI_TYPES.VENTURE)) venture.save() reload_report = self.client.get(url, follow=True) re_invalid_relation = reload_report.context['invalid_relation'] re_services_without_venture = reload_report.context[ 'services_without_venture'] self.assertEqual(len(re_invalid_relation), 1) self.assertEqual(len(re_services_without_venture), 0)