Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: fix default value (#631) #632

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions pywps/inout/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,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 @@ -126,6 +126,7 @@ def complex_proces(request, response):
ComplexInput(
'complex',
'Complex input',
min_occurs=0,
default="DEFAULT COMPLEX DATA",
supported_formats=[frmt])
],
Expand Down