def test_ensure_workspace_exists(self): ws_name = 'nonexistent-workspace' ws_namespace_uri = 'http://nonamespace.com' # Ensure that the workspace doesn't exist ws1 = gs_catalog.get_workspace(ws_name) if ws1 is not None: gs_catalog.delete(ws1) ensure_workspace_exists(gs_catalog, ws_name, ws_namespace_uri) # Check that the workspace now exists ws2 = gs_catalog.get_workspace(ws_name) self.assertNotEqual(ws2, None) # Run again to ensure a preexisting workspace doesn't throw any exceptions ensure_workspace_exists(gs_catalog, ws_name, ws_namespace_uri) gs_catalog.delete(ws2)
def get_geoserver_cascading_workspace(create=True): """Return the geoserver workspace used for cascaded services The workspace can be created it if needed. """ name = getattr(settings, "CASCADE_WORKSPACE", "cascaded-services") workspace = catalog.get_workspace(name) if workspace is None and create: uri = f"http://www.geonode.org/{name}" workspace = catalog.create_workspace(name, uri) return workspace