-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for OGC API - Features - Part 3: CQL
- Loading branch information
1 parent
8db1fbd
commit 22975cd
Showing
8 changed files
with
115 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from tests.utils import service_ok | ||
|
||
import pytest | ||
|
||
from owslib.ogcapi.records import Records | ||
|
||
SERVICE_URL = 'https://demo.pycsw.org/cite' | ||
|
||
|
||
@pytest.mark.online | ||
@pytest.mark.skipif(not service_ok(SERVICE_URL), | ||
reason='service is unreachable') | ||
def test_ogcapi_records_pygeoapi(): | ||
w = Records(SERVICE_URL) | ||
|
||
assert w.url == 'https://demo.pycsw.org/cite/' | ||
assert w.url_query_string is None | ||
|
||
api = w.api() | ||
assert api['components']['parameters'] is not None | ||
paths = api['paths'] | ||
assert paths is not None | ||
assert paths['/collections/metadata:main'] is not None | ||
|
||
conformance = w.conformance() | ||
assert len(conformance['conformsTo']) == 10 | ||
|
||
collections = w.collections() | ||
assert len(collections) > 0 | ||
|
||
record_collections = w.records() | ||
assert record_collections == ['metadata:main'] | ||
|
||
pycsw_cite_demo = w.collection('metadata:main') | ||
assert pycsw_cite_demo['id'] == 'metadata:main' | ||
assert pycsw_cite_demo['title'] == 'pycsw OGC CITE demo and Reference Implementation' # noqa | ||
assert pycsw_cite_demo['itemType'] == 'record' | ||
assert w.request == 'https://demo.pycsw.org/cite/collections/metadata:main' # noqa | ||
assert w.response is not None | ||
assert isinstance(w.response, dict) | ||
|
||
pycsw_cite_demo_queryables = w.collection_queryables('metadata:main') | ||
assert len(pycsw_cite_demo_queryables['properties'].keys()) == 60 | ||
|
||
# Minimum of limit param is 1 | ||
with pytest.raises(RuntimeError): | ||
pycsw_cite_demo_query = w.collection_items('metadata:main', limit=0) | ||
|
||
pycsw_cite_demo_query = w.collection_items('metadata:main', limit=1) | ||
assert pycsw_cite_demo_query['numberMatched'] == 12 | ||
assert pycsw_cite_demo_query['numberReturned'] == 1 | ||
assert len(pycsw_cite_demo_query['features']) == 1 | ||
|
||
pycsw_cite_demo_query = w.collection_items('metadata:main', q='lorem') | ||
assert pycsw_cite_demo_query['numberMatched'] == 5 | ||
assert pycsw_cite_demo_query['numberReturned'] == 5 | ||
assert len(pycsw_cite_demo_query['features']) == 5 | ||
|
||
cql_text = "title LIKE 'Lorem%'" | ||
pycsw_cite_demo_query = w.collection_items('metadata:main', filter=cql_text) | ||
assert pycsw_cite_demo_query['numberMatched'] == 2 | ||
assert pycsw_cite_demo_query['numberReturned'] == 2 | ||
assert len(pycsw_cite_demo_query['features']) == 2 | ||
|
||
cql_json = {'eq': [{'property': 'title'}, 'Lorem ipsum']} | ||
pycsw_cite_demo_query = w.collection_items('metadata:main', cql=cql_json) | ||
assert pycsw_cite_demo_query['numberMatched'] == 1 | ||
assert pycsw_cite_demo_query['numberReturned'] == 1 | ||
assert len(pycsw_cite_demo_query['features']) == 1 |