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.
Why these changes are being introduced: * Given the application's simplicity, the majority of the application's functionality will reside in the CLI. How this addresses that need: * Update cli.py with the application's functionality * Update dependencies * Update README.md Side effects of this change: * None Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IN-1093
- Loading branch information
Showing
7 changed files
with
558 additions
and
68 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -45,7 +45,7 @@ ignore = [ | |
"PLR0915", | ||
"S320", | ||
"S321", | ||
"G004", | ||
"G004" | ||
] | ||
|
||
# allow autofix behavior for specified rules | ||
|
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,48 @@ | ||
import logging | ||
from unittest.mock import patch | ||
|
||
from asati.cli import main | ||
|
||
|
||
def test_cli_no_options(caplog, runner): | ||
result = runner.invoke(main) | ||
@patch("asati.cli.ASnakeClient") | ||
@patch("asati.cli.pyairtable") | ||
def test_cli_new_accessions_success( | ||
mocked_airtable, mocked_asnake, aspace_record, caplog, runner | ||
): | ||
mocked_asnake.return_value.get.return_value.json.side_effect = [ | ||
[1234, 5678], | ||
aspace_record, | ||
] | ||
mocked_airtable.Api.return_value.table.return_value.create.return_value = { | ||
"fields": {"Accession Number": "2025-014"} | ||
} | ||
caplog.set_level(logging.DEBUG) | ||
result = runner.invoke(main, ["--verbose"]) | ||
assert result.exit_code == 0 | ||
assert "Logger 'root' configured with level=INFO" in caplog.text | ||
assert "Logger 'root' configured with level=DEBUG" in caplog.text | ||
assert "Running process" in caplog.text | ||
assert ( | ||
"Data extracted from ArchivesSpace: {'Accession Title': 'MIT Libraries records " | ||
"and Bibliotech newsletters 2024 July transfer', 'Accession Number': '2025-014'," | ||
" 'Current Status': 'Unassigned', 'Extent Number': 1.0, 'Extent Type': 'box(es)'}" | ||
in caplog.text | ||
) | ||
assert "Airtable row created for Accession Number: '2025-014'" in caplog.text | ||
assert ( | ||
"Updated SSM parameter '/apps/asati/last-accession-uri-id' to '5678'" | ||
in caplog.text | ||
) | ||
assert "Total time to complete process" in caplog.text | ||
|
||
|
||
def test_cli_all_options(caplog, runner): | ||
result = runner.invoke(main, ["--verbose"]) | ||
@patch("asati.cli.ASnakeClient") | ||
def test_cli_no_accessions_success(mocked_asnake, caplog, runner): | ||
mocked_asnake.return_value.get.return_value.json.return_value = [1234] | ||
result = runner.invoke(main) | ||
assert result.exit_code == 0 | ||
assert "Logger 'root' configured with level=DEBUG" in caplog.text | ||
assert "Logger 'root' configured with level=INFO" in caplog.text | ||
assert "Running process" in caplog.text | ||
assert "No new accessions to add to Airtable." in caplog.text | ||
assert "Total time to complete process" in caplog.text | ||
assert "Airtable row created for Accession Number:" not in caplog.text | ||
assert "Updated SSM parameter" not in caplog.text |