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

Handle emptry string for POSIXPath #229

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion nb2workflow/nbadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,10 @@ def handle_url_params(self, parameters, tmpdir, context={}):
if is_posix_path or is_file_url or is_file_reference:
arg_par_value = parameters.get(input_par_name, None)
if arg_par_value is None:
arg_par_value = input_par_obj['default_value']
if is_posix_path:
arg_par_value = ''
else:
arg_par_value = input_par_obj['default_value']
if validators.url(arg_par_value, simple_host=True):
logger.info(f"checking url: {arg_par_value}")
if is_mmoda_url(arg_par_value):
Expand Down
21 changes: 13 additions & 8 deletions tests/test_input_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def test_posix_download_file_with_arg(client):
r = client.get('/api/v1.0/get/testposixpath', query_string={'fits_file_path': 'https://fits.gsfc.nasa.gov/samples/testkeys.fits'})
assert r.json['output']['output_file_download'] == 'file downloaded successfully'

def test_posix_download_file_default_value_with_arg(client):
r = client.get('/api/v1.0/get/testposixpath', query_string={'fits_file_path': ''})
assert r.json['output']['output_file_download'] == 'file not downloaded'

def test_posix_download_file_extra_annotations(client):
r = client.get('/api/v1.0/get/testposixpath_extra_annotated', query_string={'fits_file_path': 'https://fits.gsfc.nasa.gov/samples/testkeys.fits'})
assert r.json['output']['output_file_download'] == 'file downloaded successfully'
Expand Down Expand Up @@ -264,14 +268,15 @@ def test_dict_wrong(client):


@pytest.mark.parametrize('inp,outp', [({'opt': None}, {'opt': None}),
({'opt': 10}, {'opt': 10.}),
({'intfloat': 25}, {'intfloat': 25.}),
({'intfloat': 25.}, {'intfloat': 25.}),
({'inten': 20}, {'inten': 20}),
({'flag': False}, {'flag': False}),
({'flag': 0}, {'flag': False}),
({'string_param': 'contains = symbol'}, {'string_param': 'contains = symbol'}),
({'otheropt': '\x00'}, {'otheropt': None})
({'opt': 10}, {'opt': 10.}),
({'intfloat': 25}, {'intfloat': 25.}),
({'intfloat': 25.}, {'intfloat': 25.}),
({'inten': 20}, {'inten': 20}),
({'flag': False}, {'flag': False}),
({'flag': 0}, {'flag': False}),
({'string_param': 'contains = symbol'}, {'string_param': 'contains = symbol'}),
({'otheropt': '\x00'}, {'otheropt': None}),
({'short_string_param': ''}, {'short_string_param': ''}),
])
def test_type_casting(client, inp, outp):
r = client.get('/api/v1.0/options')
Expand Down
3 changes: 3 additions & 0 deletions tests/test_type_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@

('foo', None, 'oda:WithNoTypeDefined', '', str, False),
({'foo': ['bar', 'baz']}, None, 'oda:WithNoTypeDefined', '', dict, False),

('', None, 'oda:POSIXPath', '', str, False)
]
# 'value,type_annotation,owl_type,extra_ttl,expected_type,expected_optional'
)
def test_reconcile_python_type(value,type_annotation,owl_type,extra_ttl,expected_type,expected_optional):
assert reconcile_python_type(value=value,
Expand Down
2 changes: 2 additions & 0 deletions tests/testfiles/multiline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Contains = Symbol\n",
"Spam Ham\n",
"''' # oda:LongString\n",
"short_string_param = 'Just a string' # oda:String\n",
"flag = True"
]
},
Expand All @@ -50,6 +51,7 @@
" intfloat = intfloat,\n",
" inten = inten,\n",
" string_param = string_param,\n",
" short_string_param = short_string_param,\n",
" flag = flag)"
]
}
Expand Down
Loading