Skip to content

Commit

Permalink
fix default value (#631)
Browse files Browse the repository at this point in the history
* ignore default when a value is required

* fixed test
  • Loading branch information
cehbrecht authored Sep 30, 2021
1 parent 584f792 commit 793ab34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
27 changes: 17 additions & 10 deletions pywps/inout/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,23 @@ def _set_default_value(self, value=None, value_type=None):
value_type = value_type or getattr(self, '_default_type')

if value:
if value_type == SOURCE_TYPE.DATA:
self.data = value
elif value_type == SOURCE_TYPE.MEMORY:
raise NotImplementedError
elif value_type == SOURCE_TYPE.FILE:
self.file = value
elif value_type == SOURCE_TYPE.STREAM:
self.stream = value
elif value_type == SOURCE_TYPE.URL:
self.url = value
# only set default when a value is optional
if self.min_occurs == 0:
if value_type == SOURCE_TYPE.DATA:
self.data = value
elif value_type == SOURCE_TYPE.MEMORY:
raise NotImplementedError
elif value_type == SOURCE_TYPE.FILE:
self.file = value
elif value_type == SOURCE_TYPE.STREAM:
self.stream = value
elif value_type == SOURCE_TYPE.URL:
self.url = value
else:
# when a value is requried the default value will be ignored
LOGGER.warning(
"The given default value will not be used"
" because is is required to provide a value.")

def _build_file_name(self, href=''):
"""Return a file name for the local system."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def complex_proces(request, response):
ComplexInput(
'complex',
'Complex input',
min_occurs=0,
default="DEFAULT COMPLEX DATA",
supported_formats=[frmt])
],
Expand Down

0 comments on commit 793ab34

Please sign in to comment.