Skip to content

Commit

Permalink
Merge pull request #852 from linchiahuisage/SYNPY-1113-store_command_…
Browse files Browse the repository at this point in the history
…positional_arg_file

SYNPY-1113-store_command_positional_arg_file
  • Loading branch information
jkiang13 authored May 21, 2021
2 parents 1967179 + 56fca24 commit 07b9714
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion synapseclient/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def store(args, syn):
# If both args.FILE and args.file specified raise error
if args.file and args.FILE:
raise ValueError('only specify one file')

if args.type == 'File' and not args.file and not args.FILE:
raise ValueError(f'{args.subparser} missing required FILE argument')
_descriptionFile_arg_check(args)

args.file = args.FILE if args.FILE is not None else args.file
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/synapseclient/unit_test_commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,3 +589,16 @@ def test_get__without_synapse_id(self):
args = parser.parse_args(['get', '-r'])
cmdline.get(args, self.syn)
assert str(ve.value) == "Missing expected id argument for use with the get command"


class TestStoreFunction:
@patch('synapseclient.client.Synapse')
def setup(self, mock_syn):
self.syn = mock_syn

def test_get__without_file_args(self):
parser = cmdline.build_parser()
args = parser.parse_args(['store', '--parentid', 'syn123', '--used', 'syn456'])
with pytest.raises(ValueError) as ve:
cmdline.store(args, self.syn)
assert str(ve.value) == "store missing required FILE argument"

0 comments on commit 07b9714

Please sign in to comment.