generated from MITLibraries/python-cli-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stub CLI commands to replace mario app
Why these changes are being introduced: This application is a replacement of an existing app written in Go. We want to ensure that all functionality of the old app (mario) is rewritten into this app. Stubbing out all of the expected CLI commands from mario will provide clear initial documentation in the codebase of what the desired end functionality should be for this rewrite, and will allow us to confirm that we've completed replacement of the full mario app functionality. How this addresses that need: * Adds stub CLI commands representing all CLI commands from the old mario app, with documentation and expected parameters but no functionality. * Adds initial tests confirming that each command can be executed successfully. * Updates the CLI to group all commands under a single main command, and updates existing tests to match. * Also updates the setup.cfg file to add pydocstyle configuration. Side effects of this change: None Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/RDI-124
- Loading branch information
Showing
3 changed files
with
216 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,84 @@ | ||
from tim.cli import main | ||
|
||
|
||
def test_cli_no_options(caplog, runner): | ||
result = runner.invoke(main) | ||
def test_main_group_no_options_configures_correctly_and_invokes_result_callback( | ||
caplog, runner | ||
): | ||
result = runner.invoke(main, ["ping"]) | ||
assert result.exit_code == 0 | ||
assert "Logger 'root' configured with level=INFO" in caplog.text | ||
assert "Running process" in caplog.text | ||
assert "Total time to complete process" in caplog.text | ||
|
||
|
||
def test_cli_all_options(caplog, runner): | ||
result = runner.invoke(main, ["--verbose"]) | ||
def test_main_group_all_options_configures_correctly_and_invokes_result_callback( | ||
caplog, runner | ||
): | ||
result = runner.invoke(main, ["--verbose", "ping"]) | ||
assert result.exit_code == 0 | ||
assert "Logger 'root' configured with level=DEBUG" in caplog.text | ||
assert "Running process" in caplog.text | ||
assert "Total time to complete process" in caplog.text | ||
|
||
|
||
def test_aliases(caplog, runner): | ||
result = runner.invoke(main, ["aliases"]) | ||
assert result.exit_code == 0 | ||
assert "'aliases' command not yet implemented" in caplog.text | ||
|
||
|
||
def test_indexes(caplog, runner): | ||
result = runner.invoke(main, ["indexes"]) | ||
assert result.exit_code == 0 | ||
assert "'indexes' command not yet implemented" in caplog.text | ||
|
||
|
||
def test_ping(caplog, runner): | ||
result = runner.invoke(main, ["ping"]) | ||
assert result.exit_code == 0 | ||
assert "'ping' command not yet implemented" in caplog.text | ||
|
||
|
||
def test_ingest_no_options(caplog, runner): | ||
result = runner.invoke( | ||
main, | ||
["ingest", "-s", "aspace", "tests/fixtures/sample-records.json"], | ||
) | ||
assert result.exit_code == 0 | ||
assert "'ingest' command not yet implemented" in caplog.text | ||
|
||
|
||
def test_ingest_all_options(caplog, runner): | ||
result = runner.invoke( | ||
main, | ||
[ | ||
"ingest", | ||
"-s", | ||
"dspace", | ||
"-c", | ||
"title", | ||
"--new", | ||
"--auto", | ||
"tests/fixtures/sample-records.json", | ||
], | ||
) | ||
assert result.exit_code == 0 | ||
assert "'ingest' command not yet implemented" in caplog.text | ||
|
||
|
||
def test_promote(caplog, runner): | ||
result = runner.invoke(main, ["promote", "-i", "test-index"]) | ||
assert result.exit_code == 0 | ||
assert "'promote' command not yet implemented" in caplog.text | ||
|
||
|
||
def test_reindex(caplog, runner): | ||
result = runner.invoke( | ||
main, ["reindex", "-i", "test-index", "-d", "destination-index"] | ||
) | ||
assert result.exit_code == 0 | ||
assert "'reindex' command not yet implemented" in caplog.text | ||
|
||
|
||
def test_delete(caplog, runner): | ||
result = runner.invoke(main, ["delete", "-i", "test-index"]) | ||
assert result.exit_code == 0 | ||
assert "'delete' command not yet implemented" in caplog.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters