def pub(): if geoserver_layer_name is not None: l = Layer.publish(package_id, resource_id, geoserver_layer_name, username, lat_field=lat_field, lng_field=lng_field) return l else: l = Layer.publish(package_id, resource_id, layer_name, username, lat_field=lat_field, lng_field=lng_field) return l
def test_create_layer(self): """Check that a layer exists once create_layer is called""" # Create a layer l = Layer(self._test_package["id"], self._test_resource["id"], "testing-layer", self.admin_user().name) # Push to Geoserver self.assertIsInstance(l.create_layer(), GeoserverLayer) # Check that the layer exists gs = Geoserver.from_ckan_config() self.assertIsInstance(gs.get_layer("testing-layer"), GeoserverLayer)
def test_remove_geo_resources(self): """Removing resources should get rid of only the "geo" resources""" # Create a layer l = Layer(self._test_package["id"], self._test_resource["id"], "testing-layer", self.admin_user().name) # Add resources l.create_geo_resources() # Remove resources l.remove_geo_resources() # Check what's left p = toolkit.get_action("package_show")(None, {"id": self._test_package_name}) self.assertEqual(len(p["resources"]), 1)
def unpub(): if geoserver_layer_name is not None: layer = Layer(geoserver=geoserver, layer_name=geoserver_layer_name, resource_id=resource_id, package_id=package_id, username=username) return layer else: layer = Layer(geoserver=geoserver, layer_name=layer_name, resource_id=resource_id, package_id=package_id, username=username) return layer
def test_remove_layer_resource_check(self): """Check that the file resource no longer includes a "layer_name" once remove_layer is called""" # Create a layer l = Layer(self._test_package["id"], self._test_resource["id"], "testing-layer", self.admin_user().name) # Push to Geoserver self.assertIsInstance(l.create_layer(), GeoserverLayer) # Remove the layer self.assertTrue(l.remove_layer()) # Check the resource resource = toolkit.get_action("resource_show")( {"user": self.admin_user().name}, {"id": self._test_resource["id"]} ) self.assertIsNone(resource.get("layer_name"))
def test_create_geo_resources(self): """Creating WFS/WMS resources should return two resources""" l = Layer(self._test_package["id"], self._test_resource["id"], "testing-layer", self.admin_user().name) self.assertEqual(len(l.create_geo_resources()), 2)