Skip to content

Commit

Permalink
Fix for Issue geopython#283 replace name with id attr for WFS3 (OGC A…
Browse files Browse the repository at this point in the history
…PI Features) Collections (geopython#284)

* update all translation files plus doc HOWTO translations

* geopython#268 drop de_DE translations ('de' only now)

* geopython#9 add auth headers for WMS OWSLib calls

* geopython#277 support ESRI ArcGIS Server token auth

* geopython#283 change name to id for Collection identifier plus tests
  • Loading branch information
justb4 committed Sep 26, 2019
1 parent 1626de0 commit deb61dc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
32 changes: 16 additions & 16 deletions GeoHealthCheck/plugins/probe/wfs3.py
Expand Up @@ -81,50 +81,50 @@ 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

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
Expand All @@ -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
Expand All @@ -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()

Expand Down
25 changes: 24 additions & 1 deletion tests/data/fixtures.json
Expand Up @@ -10,7 +10,8 @@
"tags": {
"ows": "ows",
"tiling": "tiling",
"pdok": "pdok"
"pdok": "pdok",
"ogc": "ogc"
},
"resources": {
"PDOK BAG WMS": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_resources.py
Expand Up @@ -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
Expand Down

0 comments on commit deb61dc

Please sign in to comment.