Skip to content

Commit

Permalink
Add validation check to EDR query registration (#1774)
Browse files Browse the repository at this point in the history
* Add validation check to EDR query registration

* Fix flake8

* fix edr query types
  • Loading branch information
webb-ben authored Aug 13, 2024
1 parent c1b90dc commit 71ce03e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pygeoapi/provider/base_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@

import logging

from pygeoapi.provider.base import BaseProvider
from pygeoapi.provider.base import BaseProvider, ProviderInvalidDataError

LOGGER = logging.getLogger(__name__)

EDR_QUERY_TYPES = ['position', 'radius', 'area', 'cube',
'trajectory', 'corridor', 'items',
'locations', 'instances']


class BaseEDRProvider(BaseProvider):
"""Base EDR Provider"""
Expand All @@ -55,6 +59,11 @@ def __init__(self, provider_def):
@classmethod
def register(cls):
def inner(fn):
if fn.__name__ not in EDR_QUERY_TYPES:
msg = 'Invalid EDR Query type'
LOGGER.error(msg)
raise ProviderInvalidDataError(msg)

cls.query_types.append(fn.__name__)
return fn
return inner
Expand Down

0 comments on commit 71ce03e

Please sign in to comment.