Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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')
Exemplo n.º 4
0
 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')
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
 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()
Exemplo n.º 7
0
    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')
Exemplo n.º 8
0
 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()
Exemplo n.º 9
0
 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()
Exemplo n.º 10
0
    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.'})
Exemplo n.º 11
0
 def test_provider_geostore_without_layer(self):
     setting = RoutingSettingsFactory.create(provider="geostore",
                                             crud_view=self.crud_view)
     with self.assertRaises(ValidationError):
         setting.clean()
Exemplo n.º 12
0
 def test_provider_mapbox_without_transit(self):
     setting = RoutingSettingsFactory.create(provider="mapbox",
                                             crud_view=self.crud_view)
     with self.assertRaises(ValidationError):
         setting.clean()
Exemplo n.º 13
0
 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()
Exemplo n.º 14
0
 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")