def test_add_resource_uri_multipoly(self): geobar = GeoBar(name='new geobar',geom=self.multipoly) geobar.save() kwargs = { 'pub': ['get', 'list'], 'bundles': [{ 'obj': geobar, 'response_data': {} }] } get_list = self.factory.get('/geobar/') request, args, kwargs = self.resource.add_resource_uri(get_list, [], **kwargs) data = kwargs['bundles'][0]['response_data'] self.assertEqual(data['resource_uri'], '/api/{0}/geobar/{1}/'.format(self.resource.Meta.api.name, geobar.pk))
def test_process_filters_geom_intersects(self): import json GeoBar.objects.all().delete() # delete all for easy testing geobar = GeoBar(name='new geobar', geom=self.poly) geobar.save() # # TODO: GET requests using WKT geoms will definitely push the URL max-length limit # and since they can be expensive, they are potentially harmful on large geometries # list_get = self.factory.get('/geobar/?geom__intersects='+self.point.wkt) kwargs = { 'pub': ['get', 'list'] } request, args, kwargs = self.georesource.process_filters(list_get, [], **kwargs) kwargs.update( **{ 'filters' : kwargs[ 'filters' ] } ) request, args, kwargs = self.georesource.apply_filters(list_get, [], **kwargs) self.assertEqual( kwargs[ 'total_count' ], 1)
def test_update_objs_from_data_invalid_geom(self): geobar = GeoBar( name='valid geobar', geom=self.point ) geobar.save() put_detail = self.factory.put('/geobar/{0}/'.format(geobar.id), {}) kwargs = { 'pub': ['put', 'detail'], 'bundles': [ { 'obj': geobar, 'request_data': { 'name': 'invalid geobar', 'geom': self.invalid_point_wkt, 'resource_uri': '/api/v1/geobar/{0}'.format(geobar.id), } } ] } self.assertRaises( GEOSException, self.georesource.update_objs_from_data, put_detail, **kwargs )