Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/tests/functional/test_content.py
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | def test_get_content_with_invalid_swhid(client): | ||||
{ | { | ||||
content(swhid: "swh:1:cnt:invalid") { | content(swhid: "swh:1:cnt:invalid") { | ||||
swhid | swhid | ||||
} | } | ||||
} | } | ||||
""" | """ | ||||
errors = utils.get_error_response(client, query_str) | errors = utils.get_error_response(client, query_str) | ||||
# API will throw an error in case of an invalid SWHID | # API will throw an error in case of an invalid SWHID | ||||
assert len(errors) == 1 | assert len(errors) == 2 | ||||
assert "Invalid SWHID: invalid syntax" in errors[0]["message"] | assert "Invalid SWHID: invalid syntax" in errors[1]["message"] | ||||
def test_get_content_with_invalid_hashes(client): | def test_get_content_with_invalid_hashes(client): | ||||
content = get_contents()[0] | content = get_contents()[0] | ||||
query_str = """ | query_str = """ | ||||
{ | { | ||||
contentByHash(checksums: ["blake2s256:%s", "sha1:%s", "sha1_git:%s", "sha256:%s"]) { | contentByHash(checksums: ["blake2s256:%s", "sha1:%s", "sha1_git:%s", "sha256:%s"]) { | ||||
swhid | swhid | ||||
} | } | ||||
} | } | ||||
""" | """ | ||||
errors = utils.get_error_response( | errors = utils.get_error_response( | ||||
client, | client, | ||||
query_str | query_str | ||||
% ( | % ( | ||||
"invalid", # Only one hash is invalid | "invalid", # Only one hash is invalid | ||||
content.sha1.hex(), | content.sha1.hex(), | ||||
content.sha1_git.hex(), | content.sha1_git.hex(), | ||||
content.sha256.hex(), | content.sha256.hex(), | ||||
), | ), | ||||
) | ) | ||||
# API will throw an error in case of an invalid content hash | # API will throw an error in case of an invalid content hash | ||||
assert len(errors) == 1 | assert len(errors) == 2 | ||||
assert "Invalid content checksum" in errors[0]["message"] | assert "Invalid content checksum" in errors[1]["message"] | ||||
def test_get_content_as_target(client): | def test_get_content_as_target(client): | ||||
# SWHID of a test dir with a file entry | # SWHID of a test dir with a file entry | ||||
directory_swhid = "swh:1:dir:87b339104f7dc2a8163dec988445e3987995545f" | directory_swhid = "swh:1:dir:87b339104f7dc2a8163dec988445e3987995545f" | ||||
query_str = """ | query_str = """ | ||||
{ | { | ||||
directory(swhid: "%s") { | directory(swhid: "%s") { | ||||
Show All 21 Lines |