Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/cli/test_client.py
Show First 20 Lines • Show All 689 Lines • ▼ Show 20 Lines | ): | ||||
""" | """ | ||||
api_url_basename = "deposit.test.metadataonly" | api_url_basename = "deposit.test.metadataonly" | ||||
invalid_swhid = "ssh:2:sth:xxx" | invalid_swhid = "ssh:2:sth:xxx" | ||||
metadata = atom_dataset["entry-data-with-swhid"].format(swhid=invalid_swhid) | metadata = atom_dataset["entry-data-with-swhid"].format(swhid=invalid_swhid) | ||||
metadata_path = os.path.join(tmp_path, "entry-data-with-swhid.xml") | metadata_path = os.path.join(tmp_path, "entry-data-with-swhid.xml") | ||||
with open(metadata_path, "w") as f: | with open(metadata_path, "w") as f: | ||||
f.write(metadata) | f.write(metadata) | ||||
# fmt: off | |||||
with pytest.raises(ValidationError, match="Invalid"): | with pytest.raises(ValidationError, match="Invalid"): | ||||
# fmt: off | |||||
cli_runner.invoke( | cli_runner.invoke( | ||||
cli, | cli, | ||||
[ | [ | ||||
"metadata-only", | "metadata-only", | ||||
"--url", f"https://{api_url_basename}/1", | "--url", f"https://{api_url_basename}/1", | ||||
"--username", TEST_USER["username"], | "--username", TEST_USER["username"], | ||||
"--password", TEST_USER["password"], | "--password", TEST_USER["password"], | ||||
"--metadata", metadata_path, | "--metadata", metadata_path, | ||||
Show All 12 Lines | ): | ||||
""" | """ | ||||
api_url_basename = "deposit.test.metadataonly" | api_url_basename = "deposit.test.metadataonly" | ||||
metadata = atom_dataset["entry-data-minimal"] | metadata = atom_dataset["entry-data-minimal"] | ||||
metadata_path = os.path.join(tmp_path, "entry-data-minimal.xml") | metadata_path = os.path.join(tmp_path, "entry-data-minimal.xml") | ||||
with open(metadata_path, "w") as f: | with open(metadata_path, "w") as f: | ||||
f.write(metadata) | f.write(metadata) | ||||
with pytest.raises(InputError, match="SWHID must be provided"): | with pytest.raises(InputError, match="SWHID must be provided"): | ||||
# fmt: off | |||||
cli_runner.invoke( | cli_runner.invoke( | ||||
cli, | cli, | ||||
[ | [ | ||||
"metadata-only", | "metadata-only", | ||||
"--url", f"https://{api_url_basename}/1", | "--url", f"https://{api_url_basename}/1", | ||||
"--username", TEST_USER["username"], | "--username", TEST_USER["username"], | ||||
"--password", TEST_USER["password"], | "--password", TEST_USER["password"], | ||||
"--metadata", metadata_path, | "--metadata", metadata_path, | ||||
"--format", "json", | "--format", "json", | ||||
], | ], | ||||
catch_exceptions=False, | catch_exceptions=False, | ||||
) | ) | ||||
# fmt: on | # fmt: on |