Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/cli/test_client.py
Show First 20 Lines • Show All 516 Lines • ▼ Show 20 Lines | |||||
def test_cli_deposit_status_with_output_format( | def test_cli_deposit_status_with_output_format( | ||||
output_format, callable_fn, datadir, slug, requests_mock_datadir, caplog, cli_runner | output_format, callable_fn, datadir, slug, requests_mock_datadir, caplog, cli_runner | ||||
): | ): | ||||
"""Check deposit status cli with all possible output formats (json, yaml, logging). | """Check deposit status cli with all possible output formats (json, yaml, logging). | ||||
""" | """ | ||||
api_url_basename = "deposit.test.status" | api_url_basename = "deposit.test.status" | ||||
deposit_id = 1033 | deposit_id = 1033 | ||||
deposit_status_xml_path = os.path.join( | expected_deposit_status = { | ||||
datadir, f"https_{api_url_basename}", f"1_test_{deposit_id}_status" | "deposit_id": str(deposit_id), | ||||
) | "deposit_status": "done", | ||||
with open(deposit_status_xml_path, "r") as f: | "deposit_status_detail": ( | ||||
deposit_status_xml = f.read() | "The deposit has been successfully loaded into the " | ||||
expected_deposit_status = dict(parse_xml(deposit_status_xml)) | "Software Heritage archive" | ||||
), | |||||
"deposit_swh_id": "swh:1:dir:ef04a768181417fbc5eef4243e2507915f24deea", | |||||
"deposit_swh_id_context": "swh:1:dir:ef04a768181417fbc5eef4243e2507915f24deea;origin=https://www.softwareheritage.org/check-deposit-2020-10-08T13:52:34.509655;visit=swh:1:snp:c477c6ef51833127b13a86ece7d75e5b3cc4e93d;anchor=swh:1:rev:f26f3960c175f15f6e24200171d446b86f6f7230;path=/", # noqa | |||||
"deposit_external_id": "check-deposit-2020-10-08T13:52:34.509655", | |||||
} | |||||
# fmt: off | # fmt: off | ||||
result = cli_runner.invoke( | result = cli_runner.invoke( | ||||
cli, | cli, | ||||
[ | [ | ||||
"status", | "status", | ||||
"--url", f"https://{api_url_basename}/1", | "--url", f"https://{api_url_basename}/1", | ||||
"--username", TEST_USER["username"], | "--username", TEST_USER["username"], | ||||
Show All 18 Lines | |||||
def test_cli_update_metadata_with_swhid_on_completed_deposit( | def test_cli_update_metadata_with_swhid_on_completed_deposit( | ||||
datadir, requests_mock_datadir, cli_runner | datadir, requests_mock_datadir, cli_runner | ||||
): | ): | ||||
"""Update new metadata on a completed deposit (status done) is ok | """Update new metadata on a completed deposit (status done) is ok | ||||
""" | """ | ||||
api_url_basename = "deposit.test.updateswhid" | api_url_basename = "deposit.test.updateswhid" | ||||
deposit_id = 123 | deposit_id = 123 | ||||
deposit_status_xml_path = os.path.join( | expected_deposit_status = { | ||||
datadir, f"https_{api_url_basename}", f"1_test_{deposit_id}_status" | "deposit_external_id": "check-deposit-2020-10-08T13:52:34.509655", | ||||
) | "deposit_id": str(deposit_id), | ||||
with open(deposit_status_xml_path, "r") as f: | "deposit_status": "done", | ||||
deposit_status_xml = f.read() | "deposit_status_detail": ( | ||||
expected_deposit_status = dict(parse_xml(deposit_status_xml)) | "The deposit has been successfully loaded into the " | ||||
"Software Heritage archive" | |||||
), | |||||
"deposit_swh_id": "swh:1:dir:ef04a768181417fbc5eef4243e2507915f24deea", | |||||
"deposit_swh_id_context": "swh:1:dir:ef04a768181417fbc5eef4243e2507915f24deea;origin=https://www.softwareheritage.org/check-deposit-2020-10-08T13:52:34.509655;visit=swh:1:snp:c477c6ef51833127b13a86ece7d75e5b3cc4e93d;anchor=swh:1:rev:f26f3960c175f15f6e24200171d446b86f6f7230;path=/", # noqa | |||||
} | |||||
assert expected_deposit_status["deposit_status"] == "done" | assert expected_deposit_status["deposit_status"] == "done" | ||||
assert expected_deposit_status["deposit_swh_id"] is not None | assert expected_deposit_status["deposit_swh_id"] is not None | ||||
# fmt: off | # fmt: off | ||||
result = cli_runner.invoke( | result = cli_runner.invoke( | ||||
cli, | cli, | ||||
[ | [ | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |