diff --git a/swh/deposit/tests/cli/test_client.py b/swh/deposit/tests/cli/test_client.py --- a/swh/deposit/tests/cli/test_client.py +++ b/swh/deposit/tests/cli/test_client.py @@ -356,8 +356,10 @@ https://docs.softwareheritage.org/devel/swh-deposit/getting-started.html#multisteps-deposit """ # noqa api_url = "https://deposit.test.metadata/1" + deposit_id = 666 runner = CliRunner() + # Create a partial deposit with only 1 archive result = runner.invoke( cli, [ @@ -381,12 +383,43 @@ assert result.exit_code == 0, f"unexpected output: {result.output}" actual_deposit = json.loads(result.output) assert actual_deposit == { - "deposit_id": "666", + "deposit_id": str(deposit_id), "deposit_status": "partial", "deposit_status_detail": None, "deposit_date": "Oct. 8, 2020, 4:57 p.m.", } + # Update the partial deposit with only 1 archive + runner = CliRunner() + result = runner.invoke( + cli, + [ + "upload", + "--url", + api_url, + "--username", + TEST_USER["username"], + "--password", + TEST_USER["password"], + "--archive", + sample_archive["path"], + "--deposit-id", + deposit_id, + "--partial", # in-progress: True, because remains the metadata to upload + "--slug", + slug, + "--format", + "json", + ], + ) + assert result.exit_code == 0, f"unexpected output: {result.output}" + assert result.output is not None + actual_deposit = json.loads(result.output) + # deposit update scenario actually returns a deposit status dict + assert actual_deposit["deposit_id"] == str(deposit_id) + assert actual_deposit["deposit_status"] == "partial" + + # Update the partial deposit with only some metadata (and then finalize it) # https://docs.softwareheritage.org/devel/swh-deposit/getting-started.html#add-content-or-metadata-to-the-deposit metadata_path = os.path.join(datadir, "atom", "entry-data-deposit-binary.xml") @@ -404,19 +437,20 @@ "--metadata", metadata_path, "--deposit-id", - 666, + deposit_id, "--slug", slug, "--format", "json", - ], + ], # this time, ^ we no longer flag it to partial, so the status changes to + # in-progress false ) assert result.exit_code == 0, f"unexpected output: {result.output}" assert result.output is not None actual_deposit = json.loads(result.output) # deposit update scenario actually returns a deposit status dict - assert actual_deposit["deposit_id"] == "666" + assert actual_deposit["deposit_id"] == str(deposit_id) # FIXME: should be "deposited" but current limitation in the # requests_mock_datadir_visits use, cannot find a way to make it work right now assert actual_deposit["deposit_status"] == "partial" diff --git a/swh/deposit/tests/data/https_deposit.test.metadata/1_test_666_media b/swh/deposit/tests/data/https_deposit.test.metadata/1_test_666_media new file mode 120000 --- /dev/null +++ b/swh/deposit/tests/data/https_deposit.test.metadata/1_test_666_media @@ -0,0 +1 @@ +1_test_666_metadata \ No newline at end of file