def test_basic_format_not_ascii(self): self.login() signage = SignageFactory.create(name="ééé") BladeFactory.create(signage=signage) for fmt in ('csv', 'shp', 'gpx'): response = self.client.get(self.model.get_format_list_url() + '?format=' + fmt) self.assertEqual(response.status_code, 200, "")
def test_basic_format(self): self.login() blade = BladeFactory.create() LineFactory.create(blade=blade) for fmt in ('csv', 'shp', 'gpx'): response = self.client.get(self.model.get_format_list_url() + '?format=' + fmt) self.assertEqual(response.status_code, 200, "")
def test_delete_redirection(self): self.login() signage = SignageFactory.create() blade = BladeFactory.create(signage=signage) response = self.client.post(Blade.get_delete_url(blade)) self.assertEqual(response.status_code, 302) self.assertRedirects(response, signage.get_detail_url(), status_code=302)
def test_basic_format(self): self.login() self.modelfactory.create() blade = BladeFactory.create() LineFactory.create(blade=blade) for fmt in ('csv', 'shp', 'gpx'): response = self.client.get(self.model.get_format_list_url() + '?format=' + fmt) self.assertEqual(response.status_code, 200, u"")
def test_no_html_in_csv(self): self.login() blade = BladeFactory.create() LineFactory.create(blade=blade) fmt = 'csv' response = self.client.get(self.model.get_format_list_url() + '?format=' + fmt) self.assertEqual(response.status_code, 200) self.assertEqual(response.get('Content-Type'), 'text/csv')
def test_detail_target_objects(self): self.login() if settings.TREKKING_TOPOLOGY_ENABLED: path = PathFactory.create(geom=LineString((200, 200), (300, 300))) signa = SignageFactory.create(paths=[(path, .5, .5)]) signa.save() infrastructure = InfrastructureFactory.create(paths=[(path, .5, .5)]) infrastructure.save() poi = POIFactory.create(paths=[(path, .5, .5)]) trek = TrekFactory.create(paths=[(path, .5, .5)]) service = ServiceFactory.create(paths=[(path, .5, .5)]) topo = TopologyFactory.create(paths=[(path, .5, .5)]) topo.save() path_other = PathFactory.create( geom=LineString((10000, 0), (10010, 0))) signa_other = SignageFactory.create(paths=[(path_other, .5, .5)]) signa_other.save() else: signa = SignageFactory.create(geom='SRID=2154;POINT (250 250)') infrastructure = InfrastructureFactory.create( geom='SRID=2154;POINT (250 250)') poi = POIFactory.create(geom='SRID=2154;POINT (250 250)') trek = TrekFactory.create(geom='SRID=2154;POINT (250 250)') service = ServiceFactory.create(geom='SRID=2154;POINT (250 250)') topo = TopologyFactory.create(geom='SRID=2154;POINT (250 250)') signa_other = SignageFactory.create( geom='SRID=2154;POINT (10005 0)') intervention_signa = InterventionFactory.create(target=signa) intervention_infra = InterventionFactory.create(target=infrastructure) intervention_poi = InterventionFactory.create(target=poi) intervention_trek = InterventionFactory.create(target=trek) intervention_service = InterventionFactory.create(target=service) intervention_topo = InterventionFactory.create(target=topo) blade = BladeFactory(signage=signa, number="1") intervention_blade = InterventionFactory.create(target=blade) intervention_other = InterventionFactory.create(target=signa_other) response = self.client.get(signa.get_detail_url()) self.assertEqual(response.status_code, 200) self.assertContains(response, intervention_signa.target_display) self.assertContains(response, intervention_infra.target_display) self.assertContains(response, intervention_poi.target_display) self.assertContains(response, intervention_trek.target_display) self.assertContains(response, intervention_service.target_display) self.assertContains(response, intervention_blade.target_display) self.assertContains(response, intervention_topo.target_display) self.assertNotContains(response, intervention_other.target_display)
def test_csv_format_with_lines(self): self.login() signage = SignageFactory.create(name="ééé") blade = BladeFactory.create(signage=signage) LineFactory.create(blade=blade, number=3) response = self.client.get(self.model.get_format_list_url() + '?format=csv') self.assertEqual(response.status_code, 200) self.assertEqual(response.content.split(b'\r\n')[0], b"ID,City,Signage,Printed elevation,Code,Type,Color," b"Direction,Condition,Coordinates (WGS 84 / Pseudo-Mercator),Number 1,Text 1," b"Distance 1,Time 1,Pictogram 1,Number 2,Text 2," b"Distance 2,Time 2,Pictogram 2")
def test_order_blades_C(self): signage = SignageFactory.create(code="XR2") blade_2 = BladeFactory.create(number='A', signage=signage) blade = BladeFactory.create(number='*BL', signage=signage) self.assertEqual([blade, blade_2], list(signage.order_blades))
def test_set_topology_other_error(self): blade = BladeFactory.create() infra = InfrastructureFactory.create() with self.assertRaisesRegex(ValueError, "Expecting a signage"): blade.set_topology(infra)
def test_set_topology_other_error(self): blade = BladeFactory.create() infra = InfrastructureFactory.create() with self.assertRaises(ValueError) as e: blade.set_topology(infra) self.assertEqual(e.exception.message, "Expecting a signage")
def test_last_str(self): BladeFactory(signage=self.signage, number="Z") form = BladeForm(user=self.user, initial={'signage': self.signage}) self.assertEqual(form.fields['number'].initial, None)
def test_second_int(self): BladeFactory(signage=self.signage, number="1") form = BladeForm(user=self.user, initial={'signage': self.signage}) self.assertEqual(form.fields['number'].initial, "2")