def test_manager(self): it1 = InfrastructureConditionFactory.create() it2 = InfrastructureConditionFactory.create() it3 = InfrastructureConditionFactory.create() self.assertCountEqual(InfrastructureCondition.objects.all(), [it1, it2, it3])
def get_good_data(self): PathFactory.create() return { 'name': 'test', 'description': 'oh', 'type': InfrastructureTypeFactory.create(type=INFRASTRUCTURE_TYPES.BUILDING).pk, 'condition': InfrastructureConditionFactory.create().pk, 'topology': '{"lat": 0.42, "lng": 0.666}' }
def get_good_data(self): path = PathFactory.create() return { 'name': 'test', 'description': 'oh', 'type': InfrastructureTypeFactory.create(type=INFRASTRUCTURE_TYPES.BUILDING).pk, 'condition': InfrastructureConditionFactory.create().pk, 'topology': '{"paths": [%s]}' % path.pk, }
def get_good_data(self): PathFactory.create() return { 'name': 'test', 'description': 'oh', 'structure': default_structure().pk, 'type': InfrastructureTypeFactory.create(type=INFRASTRUCTURE_TYPES.BUILDING).pk, 'condition': InfrastructureConditionFactory.create().pk, 'topology': '{"lat": 0.42, "lng": 0.666}' }
def get_good_data(self): path = PathFactory.create() return { 'name': 'test', 'description': 'oh', 'structure': default_structure().pk, 'type': InfrastructureTypeFactory.create(type=INFRASTRUCTURE_TYPES.BUILDING).pk, 'condition': InfrastructureConditionFactory.create().pk, 'topology': '{"paths": [%s]}' % path.pk, }
def test_infrastructurecondition_cannot_be_change_not_same_structure(self): self.login() structure = StructureFactory(name="Other") infra = InfrastructureConditionFactory.create(structure=structure) change_url = reverse('admin:infrastructure_infrastructurecondition_change', args=[infra.pk]) response = self.client.get(change_url) self.assertEqual(response.status_code, 302) self.assertEqual(InfrastructureCondition.objects.get(pk=self.infra.pk).label, self.infra.label) self.assertEqual(response.url, '/admin/')
def test_infrastructurecondition_cannot_be_change_not_same_structure(self): self.login() structure = StructureFactory(name="Other") infra = InfrastructureConditionFactory.create(structure=structure) change_url = reverse('admin:infrastructure_infrastructurecondition_change', args=[infra.pk]) response = self.client.get(change_url) self.assertEquals(response.status_code, 302) self.assertEqual(InfrastructureCondition.objects.get(pk=self.infra.pk).label, self.infra.label) self.assertEqual(response.url, '/admin/')
def setUp(self): self.user = UserFactory.create(password='******') self.client.login(username=self.user.username, password='******') self.user.user_permissions.add(Permission.objects.get(codename='add_draft_path')) for perm in Permission.objects.exclude(codename='can_bypass_structure'): self.user.user_permissions.add(perm) self.user.is_staff = True self.user.save() p = self.user.profile structure = StructureFactory(name="This") p.structure = structure p.save() self.infra = InfrastructureConditionFactory.create(structure=structure)
def get_good_data(self): good_data = { 'name': 'test', 'description': 'oh', 'type': InfrastructureTypeFactory.create( type=INFRASTRUCTURE_TYPES.BUILDING).pk, 'condition': InfrastructureConditionFactory.create().pk, } if settings.TREKKING_TOPOLOGY_ENABLED: path = PathFactory.create() good_data['topology'] = '{"paths": [%s]}' % path.pk else: good_data['geom'] = 'LINESTRING (0.0 0.0, 1.0 1.0)' return good_data
def get_good_data(self): data = super(SignageViewsTest, self).get_good_data() data['type'] = InfrastructureTypeFactory.create(type=INFRASTRUCTURE_TYPES.SIGNAGE).pk data['condition'] = InfrastructureConditionFactory.create().pk return data
def test_manager(self): it1 = InfrastructureConditionFactory.create() it2 = InfrastructureConditionFactory.create() it3 = InfrastructureConditionFactory.create() self.assertItemsEqual(InfrastructureCondition.objects.all(), [it1, it2, it3])
def setUp(self): self.user = SuperUserFactory.create(password='******') self.infra = InfrastructureConditionFactory.create()