Skip to content

Commit

Permalink
Tweaks to simplejson warning copy and forward/reverse validation
Browse files Browse the repository at this point in the history
  • Loading branch information
clausmith committed Jan 4, 2018
1 parent ae24aad commit a9d87ac
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
9 changes: 6 additions & 3 deletions onecodex/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def onecodex(ctx, api_key, no_pprint, verbose, telemetry):
# Show a warning if simplejson is installed
if is_simplejson_installed():
warn_simplejson()
sys.exit(1)

# create the api
no_api_subcommands = ["login", "logout"]
Expand Down Expand Up @@ -196,11 +195,15 @@ def upload(ctx, files, max_threads, clean, no_interleave, prompt, validate,
if (forward or reverse) and not (forward and reverse):
click.echo('You must specify both forward and reverse files', err=True)
sys.exit(1)
if forward:
if forward and reverse:
if len(files) > 0:
click.echo('You may not pass a FILES argument when using the '
' --forward and --reverse options.', err=True)
sys.exit(1)
files = [(forward, reverse)]
no_interleave = True
if len(files) == 0:
print(ctx.get_help())
click.echo(ctx.get_help())
return
else:
files = list(files)
Expand Down
4 changes: 2 additions & 2 deletions onecodex/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def warn_simplejson():
"# #\n" # noqa
"# You currently have simplejson installed. Unfortunately, this library does not #\n" # noqa
"# work properly alongside simplejson. Please install this library in a separate #\n" # noqa
"# virtual environment using a tool such as virtualenv. For more information, see #\n" # noqa
"# https://virtualenv.pypa.io/en/stable/. #\n" # noqa
"# virtual environment using a tool such as virtualenv or uninstall simplejson. #\n" # noqa
"# For more information, see https://virtualenv.pypa.io/en/stable/. #\n" # noqa
"# #\n" # noqa
"######################################################################################\n") # noqa)
echo(m, err=True)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ def test_paired_files(runner, upload_mocks):
assert 'You must specify both forward and reverse files' in result6.output
assert result6.exit_code != 0

# Check with --forward, --reverse, and files, should fail
args = ['--api-key', '01234567890123456789012345678901', 'upload', '--forward', f,
'--reverse', f2, f2]
with mock.patch(patch1) as mp, mock.patch(patch2) as mp2:
result7 = runner.invoke(Cli, args)
assert 'You may not pass a FILES argument' in result7.output
assert result7.exit_code != 0


def test_large_uploads(runner, upload_mocks, monkeypatch):
# a lot of funky mocking
Expand Down
1 change: 0 additions & 1 deletion tests/test_simplejson.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@

def test_simplejson(runner, upload_mocks):
result = runner.invoke(Cli, ['upload'])
assert result.exit_code != 0
assert "You currently have simplejson installed" in result.output

0 comments on commit a9d87ac

Please sign in to comment.