Skip to content

Commit

Permalink
properly handle optional reference in UOM
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Oct 28, 2023
1 parent a209784 commit 73ae6d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pywps/inout/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, uom='', reference=None):
self.reference = reference

if self.reference is None:
self.reference = OGCUNIT[self.uom]
self.reference = OGCUNIT.get(self.uom, '')

@property
def json(self):
Expand Down
14 changes: 11 additions & 3 deletions tests/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pywps import LiteralOutput, ComplexOutput, BoundingBoxOutput
from pywps import get_ElementMakerForVersion, OGCTYPE, Format, NAMESPACES, OGCUNIT
from pywps.inout.literaltypes import LITERAL_DATA_TYPES
from pywps.inout.basic import UOM
from pywps.app.basic import get_xpath_ns
from pywps.app.Common import Metadata
from pywps.inout.literaltypes import AllowedValue
Expand Down Expand Up @@ -41,7 +42,7 @@ def get_default_value(el):
def get_single_uom(el):
ows = el.nsmap["ows"]
unit = el.text
href = el.attrib[f"{{{ows}}}reference"]
href = el.attrib.get(f"{{{ows}}}reference")
return {"uom": unit, "reference": href}


Expand Down Expand Up @@ -286,13 +287,20 @@ def hello(request):
inputs=[LiteralInput('the_number',
'Input number',
data_type='float',
uoms=['metre', 'feet'])])
uoms=[
'metre',
'feet',
'undef',
UOM('pixel', 'http://schema.com/#pixel'),
])])
result = self.describe_process(hello_process)
uoms = {
'default': {'uom': 'metre', 'reference': OGCUNIT['metre']},
'supported': [
{'uom': 'metre', 'reference': OGCUNIT['metre']},
{'uom': 'feet', 'reference': OGCUNIT['feet']}
{'uom': 'feet', 'reference': OGCUNIT['feet']},
{'uom': 'undef', 'reference': None}, # no mapping to known OGC URN
{'uom': 'pixel', 'reference': 'http://schema.com/#pixel'},
]
}
assert result.inputs == [('the_number', 'literal', 'float', None, uoms)]
Expand Down

0 comments on commit 73ae6d9

Please sign in to comment.