handle datetime errors in config (#659) (#661)

This commit is contained in:
Tom Kralidis
2021-03-18 06:25:39 -04:00
committed by GitHub
parent e2e2b7d671
commit b40297a864
2 changed files with 14 additions and 4 deletions
+9 -4
View File
@@ -2556,10 +2556,15 @@ def validate_datetime(resource_def, datetime_=None):
te = resource_def['temporal']
if te['begin'] is not None and te['begin'].tzinfo is None:
te['begin'] = te['begin'].replace(tzinfo=pytz.UTC)
if te['end'] is not None and te['end'].tzinfo is None:
te['end'] = te['end'].replace(tzinfo=pytz.UTC)
try:
if te['begin'] is not None and te['begin'].tzinfo is None:
te['begin'] = te['begin'].replace(tzinfo=pytz.UTC)
if te['end'] is not None and te['end'].tzinfo is None:
te['end'] = te['end'].replace(tzinfo=pytz.UTC)
except AttributeError:
msg = 'Configured times should be RFC3339'
LOGGER.error(msg)
raise ValueError(msg)
if '/' in datetime_: # envelope
LOGGER.debug('detected time range')
+5
View File
@@ -503,6 +503,11 @@ def test_get_collection_items(config, api_):
assert code == 200
rsp_headers, code, response = api_.get_collection_items(
req_headers, {'datetime': '2005-04-22'}, 'lakes')
assert code == 400
rsp_headers, code, response = api_.get_collection_items(
req_headers, {'skipGeometry': 'true'}, 'obs')