Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/cli/test_client.py
Show First 20 Lines • Show All 1,005 Lines • ▼ Show 20 Lines | |||||
): | ): | ||||
"""Deposit cli should warn when provided metadata xml is missing 'origins' tags | """Deposit cli should warn when provided metadata xml is missing 'origins' tags | ||||
""" | """ | ||||
# For the next deposit, no warning should be logged as either <swh:create_origin> or | # For the next deposit, no warning should be logged as either <swh:create_origin> or | ||||
# <swh:origin_to_add> are provided, and <swh:metadata-provenance-url> is always | # <swh:origin_to_add> are provided, and <swh:metadata-provenance-url> is always | ||||
# provided. | # provided. | ||||
metadata_raw = atom_dataset[metadata_entry_key] % "some-url" | raw_metadata = atom_dataset[metadata_entry_key] % "some-url" | ||||
metadata_path = os.path.join(tmp_path, "metadata-with-origin-tag-to-deposit.xml") | metadata_path = os.path.join(tmp_path, "metadata-with-origin-tag-to-deposit.xml") | ||||
with open(metadata_path, "w") as f: | with open(metadata_path, "w") as f: | ||||
f.write(metadata_raw) | f.write(raw_metadata) | ||||
# fmt: off | # fmt: off | ||||
cli_runner.invoke( | 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 10 Lines | |||||
def test_cli_deposit_warning_missing_provenance_url( | def test_cli_deposit_warning_missing_provenance_url( | ||||
tmp_path, atom_dataset, caplog, cli_runner, requests_mock_datadir, | tmp_path, atom_dataset, caplog, cli_runner, requests_mock_datadir, | ||||
): | ): | ||||
"""Deposit cli should warn when no metadata provenance is provided | """Deposit cli should warn when no metadata provenance is provided | ||||
""" | """ | ||||
atom_template = atom_dataset["entry-data-with-add-to-origin-no-prov"] | atom_template = atom_dataset["entry-data-with-add-to-origin-no-prov"] | ||||
metadata_raw = atom_template % "some-url" | raw_metadata = atom_template % "some-url" | ||||
metadata_path = os.path.join(tmp_path, "metadata-with-missing-prov-url.xml") | metadata_path = os.path.join(tmp_path, "metadata-with-missing-prov-url.xml") | ||||
with open(metadata_path, "w") as f: | with open(metadata_path, "w") as f: | ||||
f.write(metadata_raw) | f.write(raw_metadata) | ||||
# fmt: off | # fmt: off | ||||
cli_runner.invoke( | 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 20 Lines • Show All 121 Lines • Show Last 20 Lines |