From deb61dc56f29184d48d15b7478cbbba33953b763 Mon Sep 17 00:00:00 2001 From: Just van den Broecke Date: Thu, 26 Sep 2019 20:42:38 +0200 Subject: [PATCH] Fix for Issue #283 replace name with id attr for WFS3 (OGC API Features) Collections (#284) * update all translation files plus doc HOWTO translations * geopython/GeoHealthCheck#268 drop de_DE translations ('de' only now) * geopython/GeoHealthCheck#9 add auth headers for WMS OWSLib calls * #277 support ESRI ArcGIS Server token auth * geopython/GeoHealthCheck#283 change name to id for Collection identifier plus tests --- GeoHealthCheck/plugins/probe/wfs3.py | 32 ++++++++++++++-------------- tests/data/fixtures.json | 25 +++++++++++++++++++++- tests/test_resources.py | 2 +- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/GeoHealthCheck/plugins/probe/wfs3.py b/GeoHealthCheck/plugins/probe/wfs3.py index a67d47fe..422853ff 100644 --- a/GeoHealthCheck/plugins/probe/wfs3.py +++ b/GeoHealthCheck/plugins/probe/wfs3.py @@ -81,42 +81,42 @@ def perform_request(self): # "full" could be all layers. result = Result(True, 'Test Collections') result.start() - coll_name = '' + coll_id = '' try: for collection in collections: - coll_name = collection['name'] - coll_name = coll_name.encode('utf-8') + coll_id = collection['id'] + coll_id = coll_id.encode('utf-8') try: - coll = wfs3.collection(coll_name) + coll = wfs3.collection(coll_id) # TODO: Maybe also add crs - for attr in ['name', 'links']: + for attr in ['id', 'links']: val = coll.get(attr, None) if val is None: msg = '%s: missing attr: %s' \ - % (coll_name, attr) + % (coll_id, attr) result = push_result( self, result, False, msg, 'Test Collection') continue except Exception as e: msg = 'GetCollection %s: OWSLib err: %s ' \ - % (str(e), coll_name) + % (str(e), coll_id) result = push_result( self, result, False, msg, 'Test GetCollection') continue try: - items = wfs3.collection_items(coll_name, limit=1) + items = wfs3.collection_items(coll_id, limit=1) except Exception as e: - msg = 'GetItems %s: OWSLib err: %s ' % (str(e), coll_name) + msg = 'GetItems %s: OWSLib err: %s ' % (str(e), coll_id) result = push_result( self, result, False, msg, 'Test GetItems') continue features = items.get('features', None) if features is None: - msg = 'GetItems %s: No features attr' % coll_name + msg = 'GetItems %s: No features attr' % coll_id result = push_result( self, result, False, msg, 'Test GetItems') continue @@ -124,7 +124,7 @@ def perform_request(self): type = items.get('type', '') if type != 'FeatureCollection': msg = '%s:%s type not FeatureCollection: %s' \ - % (coll_name, type, val) + % (coll_id, type, val) result = push_result( self, result, False, msg, 'Test GetItems') continue @@ -133,10 +133,10 @@ def perform_request(self): fid = items['features'][0]['id'] try: - item = wfs3.collection_item(coll_name, fid) + item = wfs3.collection_item(coll_id, fid) except Exception as e: msg = 'GetItem %s: OWSLib err: %s' \ - % (str(e), coll_name) + % (str(e), coll_id) result = push_result( self, result, False, msg, 'Test GetItem') continue @@ -146,21 +146,21 @@ def perform_request(self): val = item.get(attr, None) if val is None: msg = '%s:%s missing attr: %s' \ - % (coll_name, str(fid), attr) + % (coll_id, str(fid), attr) result = push_result( self, result, False, msg, 'Test GetItem') continue if attr == 'type' and val != 'Feature': msg = '%s:%s type not Feature: %s' \ - % (coll_name, str(fid), val) + % (coll_id, str(fid), val) result = push_result( self, result, False, msg, 'Test GetItem') continue except Exception as err: result.set(False, 'Collection err: %s : e=%s' - % (coll_name, str(err))) + % (coll_id, str(err))) result.stop() diff --git a/tests/data/fixtures.json b/tests/data/fixtures.json index f6f9f434..12eb2942 100644 --- a/tests/data/fixtures.json +++ b/tests/data/fixtures.json @@ -10,7 +10,8 @@ "tags": { "ows": "ows", "tiling": "tiling", - "pdok": "pdok" + "pdok": "pdok", + "ogc": "ogc" }, "resources": { "PDOK BAG WMS": { @@ -84,6 +85,16 @@ "tiling", "pdok" ] + }, + "PYGEOAPI FEATURES": { + "owner": "admin", + "resource_type": "OSGeo:WFS3", + "active": true, + "title": "pygeoapi - master", + "url": "https://demo.pygeoapi.io/master", + "tags": [ + "ogc" + ] } }, "probe_vars": { @@ -200,6 +211,18 @@ "y": "0", "extension" : "png" } + }, + "PYGEOAPI - Drilldown": { + "resource": "PYGEOAPI FEATURES", + "probe_class": "GeoHealthCheck.plugins.probe.wfs3.WFS3Drilldown", + "parameters": { + "drilldown_level": "full" + } + }, + "PYGEOAPI - OpenAPI": { + "resource": "PYGEOAPI FEATURES", + "probe_class": "GeoHealthCheck.plugins.probe.wfs3.WFS3OpenAPIValidator", + "parameters": {} } }, "check_vars": { diff --git a/tests/test_resources.py b/tests/test_resources.py index 03dc0e4a..a4f89325 100644 --- a/tests/test_resources.py +++ b/tests/test_resources.py @@ -65,7 +65,7 @@ def tearDown(self): def testResourcesPresent(self): resources = Resource.query.all() - self.assertEqual(len(resources), 7) + self.assertEqual(len(resources), 8) def testRunResoures(self): # Do the whole healthcheck for all Resources for now