From cc6dc2e33b3c33bd6e199d8ab7dd7c3e4ce8ffae Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Thu, 18 Feb 2021 21:54:48 -0500 Subject: [PATCH] update config, fix ref (#634) --- pygeoapi-config.yml | 3 --- pygeoapi/provider/tinydb_.py | 6 +++--- tests/test_tinydb_catalogue_provider.py | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pygeoapi-config.yml b/pygeoapi-config.yml index 980a813..9bd8b64 100644 --- a/pygeoapi-config.yml +++ b/pygeoapi-config.yml @@ -226,9 +226,6 @@ resources: spatial: bbox: [-180,-90,180,90] crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84 - temporal: - begin: 1867-07-01 - end: null # or empty (either means open ended) providers: - type: record name: TinyDBCatalogue diff --git a/pygeoapi/provider/tinydb_.py b/pygeoapi/provider/tinydb_.py index 850b451..818841c 100644 --- a/pygeoapi/provider/tinydb_.py +++ b/pygeoapi/provider/tinydb_.py @@ -139,9 +139,9 @@ class TinyDBCatalogueProvider(BaseProvider): time_begin, time_end = datetime_.split('/') if time_begin != '..': - QUERY.append("(Q.properties[self.time_field]>='{}')".format(datetime_)) # noqa + QUERY.append("(Q.properties[self.time_field]>='{}')".format(time_begin)) # noqa if time_end != '..': - QUERY.append("(Q.properties[self.time_field]<='{}')".format(datetime_)) # noqa + QUERY.append("(Q.properties[self.time_field]<='{}')".format(time_end)) # noqa else: # time instant LOGGER.debug('detected time instant') @@ -161,8 +161,8 @@ class TinyDBCatalogueProvider(BaseProvider): LOGGER.debug('SEARCH_STRING: {}'.format(SEARCH_STRING)) LOGGER.debug('querying database') - if len(QUERY) > 0: + LOGGER.debug('running eval on {}'.format(SEARCH_STRING)) results = eval(SEARCH_STRING) else: results = self.db.all() diff --git a/tests/test_tinydb_catalogue_provider.py b/tests/test_tinydb_catalogue_provider.py index b88f954..a088f58 100644 --- a/tests/test_tinydb_catalogue_provider.py +++ b/tests/test_tinydb_catalogue_provider.py @@ -53,7 +53,8 @@ def config(): 'name': 'TinyDBCatalogue', 'type': 'feature', 'data': path, - 'id_field': 'externalId' + 'id_field': 'externalId', + 'time_field': 'record-created' } @@ -81,6 +82,18 @@ def test_query(config): assert len(results['features']) == 1 assert results['features'][0]['id'] == '07b7ef80-6061-43fc-b874-e2800e9ae547' # noqa + results = p.query(datetime_='2020/..') + assert len(results['features']) == 6 + assert results['features'][0]['id'] == '4e81a467-fc14-4fa0-a1d6-9d65336587c6' # noqa + + results = p.query(datetime_='../2020') + assert len(results['features']) == 4 + assert results['features'][0]['id'] == '07b7ef80-6061-43fc-b874-e2800e9ae547' # noqa + + results = p.query(datetime_='2020-09-17/2020-12-01') + assert len(results['features']) == 6 + assert results['features'][0]['id'] == '4e81a467-fc14-4fa0-a1d6-9d65336587c6' # noqa + results = p.query(bbox=[-154, 42, -52, 84]) assert len(results['features']) == 10 assert results['features'][0]['id'] == '07b7ef80-6061-43fc-b874-e2800e9ae547' # noqa