def test_same_layer(self): RoutingSettingsFactory.create(provider="geostore", layer=self.layer, crud_view=self.crud_view) with self.assertRaises(IntegrityError): RoutingSettingsFactory.create(provider="geostore", layer=self.layer, crud_view=self.crud_view)
def test_same_transit(self): RoutingSettingsFactory.create(provider="mapbox", mapbox_transit='cycling', crud_view=self.crud_view) with self.assertRaises(IntegrityError): RoutingSettingsFactory.create(provider="mapbox", mapbox_transit='cycling', crud_view=self.crud_view)
def test_same_layer_different_crud_view(self): RoutingSettingsFactory.create(provider="mapbox", mapbox_transit='cycling', crud_view=self.crud_view) setting = RoutingSettingsFactory.create(provider="mapbox", mapbox_transit='cycling', crud_view=self.other_crud_view, label="Other") self.assertEqual(str(setting), 'Other')
def test_same_layer_clean_different_crud_view(self): RoutingSettingsFactory.create(provider="geostore", layer=self.layer, crud_view=self.crud_view) setting = RoutingSettingsFactory.build(provider="geostore", layer=self.layer, crud_view=self.other_crud_view, label="Other") setting.clean() self.assertEqual(str(setting), 'Other')
def test_same_layer_clean(self): RoutingSettingsFactory.create(provider="geostore", layer=self.layer, crud_view=self.crud_view) setting = RoutingSettingsFactory.build(provider="geostore", layer=self.layer, crud_view=self.crud_view) with self.assertRaisesRegex(ValidationError, 'This layer is already used'): setting.clean()
def test_same_transit_clean(self): RoutingSettingsFactory.create(provider="mapbox", mapbox_transit='cycling', crud_view=self.crud_view) setting = RoutingSettingsFactory.build(provider="mapbox", mapbox_transit='cycling', crud_view=self.crud_view) with self.assertRaisesRegex(ValidationError, 'This transit is already used'): setting.clean()
def test_routing_settings_crudview_detail(self): RoutingSettingsFactory.create(provider="mapbox", mapbox_transit="driving", crud_view=self.view_1) response = self.client.get( reverse('crudview-detail', args=(self.view_1.pk, ))) self.assertEqual(response.status_code, status.HTTP_200_OK) data = response.json() routing_settings = data['routing_settings'] self.assertEqual(routing_settings[0]['provider']['name'], "mapbox") self.assertEqual(routing_settings[0]['provider']['options']["transit"], 'driving')
def test_layer_not_routable(self): layer = LayerFactory(routable=False) setting = RoutingSettingsFactory.create(provider="geostore", layer=layer, crud_view=self.crud_view) with self.assertRaises(ValidationError): setting.clean()
def test_provider_with_layer_and_transit(self): layer = LayerFactory(routable=True) setting = RoutingSettingsFactory.create(provider="geostore", mapbox_transit='cycling', layer=layer, crud_view=self.crud_view) with self.assertRaises(ValidationError): setting.clean()
def test_routing_settings_geostorecrudview_detail(self): layer = LayerFactory.create(routable=True) RoutingSettingsFactory.create(provider="geostore", layer=layer, crud_view=self.view_1) response = self.client.get( reverse('crudview-detail', args=(self.view_1.pk, ))) self.assertEqual(response.status_code, status.HTTP_200_OK) data = response.json() routing_settings = data['routing_settings'] self.assertEqual(routing_settings[0]['provider']['name'], "geostore") self.assertEqual(routing_settings[0]['provider']['options']['url'], reverse('layer-route', args=[layer.pk])) response = self.client.post(reverse('layer-route', args=[layer.pk]), { 'geom': 'SRID=2154;LINESTRING(0 0, 1 1)', }) data = response.json() self.assertNotEqual(data, {'detail': 'Not found.'})
def test_provider_geostore_without_layer(self): setting = RoutingSettingsFactory.create(provider="geostore", crud_view=self.crud_view) with self.assertRaises(ValidationError): setting.clean()
def test_provider_mapbox_without_transit(self): setting = RoutingSettingsFactory.create(provider="mapbox", crud_view=self.crud_view) with self.assertRaises(ValidationError): setting.clean()
def test_provider_geostore_with_transit(self): setting = RoutingSettingsFactory.create(provider="geostore", mapbox_transit='cycling', crud_view=self.crud_view) with self.assertRaises(ValidationError): setting.clean()
def test_str(self): setting = RoutingSettingsFactory.create(provider="mapbox", mapbox_transit="driving", crud_view=self.crud_view, label="MapBox Driving") self.assertEqual(str(setting), "MapBox Driving")