Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/cli/test_client.py
Show First 20 Lines • Show All 373 Lines • ▼ Show 20 Lines | expected_error_log_record = ( | ||||
), | ), | ||||
) | ) | ||||
assert expected_error_log_record in caplog.record_tuples | assert expected_error_log_record in caplog.record_tuples | ||||
def test_cli_single_deposit_slug_generation( | def test_cli_single_deposit_slug_generation( | ||||
sample_archive, patched_tmp_path, requests_mock_datadir, cli_runner | sample_archive, patched_tmp_path, requests_mock_datadir, cli_runner | ||||
): | ): | ||||
"""Single deposit scenario without providing the slug, the slug is generated nonetheless | """Single deposit scenario without providing the slug, it should | ||||
https://docs.softwareheritage.org/devel/swh-deposit/getting-started.html#single-deposit | not be generated. | ||||
""" # noqa | """ | ||||
metadata_path = os.path.join(patched_tmp_path, "metadata.xml") | metadata_path = os.path.join(patched_tmp_path, "metadata.xml") | ||||
# fmt: off | # fmt: off | ||||
result = cli_runner.invoke( | result = cli_runner.invoke( | ||||
cli, | cli, | ||||
[ | [ | ||||
"upload", | "upload", | ||||
"--url", "https://deposit.swh.test/1", | "--url", "https://deposit.swh.test/1", | ||||
"--username", TEST_USER["username"], | "--username", TEST_USER["username"], | ||||
Show All 11 Lines | assert json.loads(result.output) == { | ||||
"deposit_status": "partial", | "deposit_status": "partial", | ||||
"deposit_status_detail": None, | "deposit_status_detail": None, | ||||
"deposit_date": "Oct. 8, 2020, 4:57 p.m.", | "deposit_date": "Oct. 8, 2020, 4:57 p.m.", | ||||
} | } | ||||
with open(metadata_path) as fd: | with open(metadata_path) as fd: | ||||
metadata_xml = fd.read() | metadata_xml = fd.read() | ||||
actual_metadata = dict(parse_xml(metadata_xml)) | actual_metadata = dict(parse_xml(metadata_xml)) | ||||
assert actual_metadata["codemeta:identifier"] is not None | assert "codemeta:identifier" not in actual_metadata | ||||
def test_cli_multisteps_deposit( | def test_cli_multisteps_deposit( | ||||
sample_archive, datadir, slug, requests_mock_datadir, cli_runner | sample_archive, datadir, slug, requests_mock_datadir, cli_runner | ||||
): | ): | ||||
""" First deposit a partial deposit (no metadata, only archive), then update the metadata part. | """ First deposit a partial deposit (no metadata, only archive), then update the metadata part. | ||||
https://docs.softwareheritage.org/devel/swh-deposit/getting-started.html#multisteps-deposit | https://docs.softwareheritage.org/devel/swh-deposit/getting-started.html#multisteps-deposit | ||||
""" # noqa | """ # noqa | ||||
▲ Show 20 Lines • Show All 219 Lines • Show Last 20 Lines |