From 58eddd08048ccfd72a14f4a5a4d64d75832e8337 Mon Sep 17 00:00:00 2001 From: Vaibhav Mule Date: Thu, 4 Oct 2018 22:01:20 +0530 Subject: [PATCH] [MRG + 1] Test UsageError for CLI (#122) * add .vscode * add tests for UsageError * fix pep8 --- .gitignore | 3 +++ tests/test_cli.py | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1b1d061e..0a92ca02 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ coverage.xml .pytest_cache/ _build/ + +# vscode +.vscode \ No newline at end of file diff --git a/tests/test_cli.py b/tests/test_cli.py index 01889920..4d1b7d95 100755 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -22,6 +22,16 @@ def test_cli_lattice(): assert result.exit_code == 0 assert result.output == 'Found 1 tables\n' + result = runner.invoke(cli, ['--format', 'csv', + 'lattice', infile]) + output_error = 'Error: Please specify output file path using --output' + assert output_error in result.output + + result = runner.invoke(cli, ['--output', outfile, + 'lattice', infile]) + format_error = 'Please specify output file format using --format' + assert format_error in result.output + def test_cli_stream(): with TemporaryDirectory() as tempdir: @@ -31,4 +41,12 @@ def test_cli_stream(): result = runner.invoke(cli, ['--format', 'csv', '--output', outfile, 'stream', infile]) assert result.exit_code == 0 - assert result.output == 'Found 1 tables\n' \ No newline at end of file + assert result.output == 'Found 1 tables\n' + + result = runner.invoke(cli, ['--format', 'csv', 'stream', infile]) + output_error = 'Error: Please specify output file path using --output' + assert output_error in result.output + + result = runner.invoke(cli, ['--output', outfile, 'stream', infile]) + format_error = 'Please specify output file format using --format' + assert format_error in result.output