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.
* Update formatting of click options * Shift reconcile functionality to BaseWorkflow.reconcile_bitstreams_and_metadata method and add corresponding unit tests * Add unit tests for BaseWorkflow's load and get_workflow methods * Refactor get_workflow method to use subclasses * Remove WORKFLOWS constant from config.py * Add InvalidWorkflowNameError exception * Replace setdefault call with defaultdict in build_bitstream_dict function * Remove file type filtering from build_bitstream_dict function and remove related unit and CLI tests
- Loading branch information
Showing
9 changed files
with
119 additions
and
133 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
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
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 |
---|---|---|
@@ -1,63 +1,25 @@ | ||
from dsc.cli import main | ||
|
||
|
||
def test_reconcile_with_file_type_success( | ||
caplog, runner, mocked_s3, base_workflow_instance, s3_client | ||
): | ||
def test_reconcile_success(caplog, runner, mocked_s3, base_workflow_instance, s3_client): | ||
s3_client.put_file(file_content="", bucket="dsc", key="test/batch-aaa/123_01.pdf") | ||
s3_client.put_file(file_content="", bucket="dsc", key="test/batch-aaa/123_02.pdf") | ||
s3_client.put_file(file_content="", bucket="dsc", key="test/batch-aaa/123_02.jpg") | ||
s3_client.put_file(file_content="", bucket="dsc", key="test/batch-aaa/456_01.pdf") | ||
s3_client.put_file(file_content="", bucket="dsc", key="test/batch-aaa/789_01.jpg") | ||
result = runner.invoke( | ||
main, | ||
[ | ||
"--workflow_name", | ||
"--workflow-name", | ||
"test", | ||
"--batch_id", | ||
"batch-aaa", | ||
"--collection_handle", | ||
"--collection-handle", | ||
"123.4/5678", | ||
"reconcile", | ||
"--file_type", | ||
"pdf", | ||
], | ||
) | ||
assert result.exit_code == 0 | ||
assert "Item identifiers and bitstreams successfully matched: ['123']" in caplog.text | ||
assert ( | ||
"No bitstreams found for the following item identifiers: {'789'}" in caplog.text | ||
) | ||
assert ( | ||
"No item identifiers found for the following bitstreams: {'456'}" in caplog.text | ||
) | ||
assert "Total time elapsed" in caplog.text | ||
|
||
|
||
def test_reconcile_without_file_type_success( | ||
caplog, runner, mocked_s3, base_workflow_instance, s3_client | ||
): | ||
s3_client.put_file(file_content="", bucket="dsc", key="test/batch-aaa/123_01.pdf") | ||
s3_client.put_file(file_content="", bucket="dsc", key="test/batch-aaa/123_02.pdf") | ||
s3_client.put_file(file_content="", bucket="dsc", key="test/batch-aaa/456_01.pdf") | ||
s3_client.put_file(file_content="", bucket="dsc", key="test/batch-aaa/789_01.jpg") | ||
result = runner.invoke( | ||
main, | ||
[ | ||
"--workflow_name", | ||
"test", | ||
"--batch_id", | ||
"--batch-id", | ||
"batch-aaa", | ||
"--collection_handle", | ||
"123.4/5678", | ||
"reconcile", | ||
], | ||
) | ||
assert result.output == "" | ||
assert result.exit_code == 0 | ||
assert ( | ||
"Item identifiers and bitstreams successfully matched: ['123', '789']" | ||
in caplog.text | ||
) | ||
assert ( | ||
"No item identifiers found for the following bitstreams: {'456'}" in caplog.text | ||
) | ||
assert "Item identifiers and bitstreams matched: ['123']" in caplog.text | ||
assert "No bitstreams found for these item identifiers: {'789'}" in caplog.text | ||
assert "No item identifiers found for these bitstreams: {'456'}" in caplog.text | ||
assert "Total time elapsed" 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