Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Schorb
VolumeAlign
Commits
f1e2602d
Commit
f1e2602d
authored
Jun 21, 2022
by
Martin Schorb
Browse files
test args2string
parent
a7631b64
Changes
3
Hide whitespace changes
Inline
Side-by-side
dashUI/utils/launch_jobs.py
View file @
f1e2602d
...
...
@@ -20,7 +20,11 @@ import requests
def
args2string
(
args
,
separator
=
'='
):
"""
Converts arguments as list or dict into a tring to be issued on CLI
Converts arguments as list or dict into a string to be issued on CLI.
If a keyword argument contains a list, it will be issued multiple times.
{'arg: [1,2,3]} -> ' arg=1 arg=2 arg=3 '
This is according to what some Render CL scripts expect when defining
multiple input files.
:param args: list, dict or str of command line arguments
:param str separator: char to separate/link arguments
...
...
@@ -31,12 +35,12 @@ def args2string(args, separator='='):
if
args
is
None
:
argstring
=
''
elif
type
(
args
)
==
list
:
argstring
=
" "
.
join
(
map
(
str
,
args
))
argstring
=
' '
+
" "
.
join
(
map
(
str
,
args
))
elif
type
(
args
)
==
dict
:
argstring
=
str
()
for
item
in
args
.
items
():
if
type
(
item
[
1
])
is
list
:
argstring
+=
' '
+
' '
.
join
([
str
(
item
[
0
])
+
separator
+
currit
for
currit
in
item
[
1
]])
argstring
+=
' '
+
' '
.
join
([
str
(
item
[
0
])
+
separator
+
str
(
currit
)
for
currit
in
item
[
1
]])
else
:
argstring
+=
' '
+
separator
.
join
(
map
(
str
,
item
))
elif
type
(
args
)
==
str
:
...
...
test/test_launch_jobs.py
0 → 100644
View file @
f1e2602d
#!/usr/bin/env python
'''
tests for functionality in dashUI.utils.launch_jobs
'''
import
os
import
pytest
from
dashUI.utils.launch_jobs
import
*
# test conversion of argstrings
def
test_args2string
():
# test Type Error
with
pytest
.
raises
(
TypeError
):
# number
args2string
(
5
)
# module
args2string
(
os
)
inlist
=
[
1
,
'a'
,
'f'
]
expectedargs
=
' 1 a f '
assert
args2string
(
inlist
)
==
expectedargs
indict
=
{
'arg1'
:
5
,
'arg2'
:
'content'
,
'arg3'
:
[
1
,
2
,
3
]}
expectedargs
=
' arg1=5 arg2=content arg3=1 arg3=2 arg3=3 '
assert
args2string
(
indict
)
==
expectedargs
test/test_status.py
deleted
100644 → 0
View file @
a7631b64
#!/usr/bin/env python
'''
'''
import
os
import
pytest
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment