Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/common/test_service.py
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | def test_lookup_hash_does_not_exist(): | ||||
assert actual_lookup == {"found": None, "algo": "sha1_git"} | assert actual_lookup == {"found": None, "algo": "sha1_git"} | ||||
@given(content()) | @given(content()) | ||||
def test_lookup_hash_exist(archive_data, content): | def test_lookup_hash_exist(archive_data, content): | ||||
actual_lookup = service.lookup_hash("sha1:%s" % content["sha1"]) | actual_lookup = service.lookup_hash("sha1:%s" % content["sha1"]) | ||||
content_metadata = archive_data.content_get_metadata(content["sha1"]) | content_metadata = archive_data.content_get(content["sha1"]) | ||||
assert {"found": content_metadata, "algo": "sha1"} == actual_lookup | assert {"found": content_metadata, "algo": "sha1"} == actual_lookup | ||||
def test_search_hash_does_not_exist(): | def test_search_hash_does_not_exist(): | ||||
unknown_content_ = random_content() | unknown_content_ = random_content() | ||||
actual_lookup = service.search_hash("sha1_git:%s" % unknown_content_["sha1_git"]) | actual_lookup = service.search_hash("sha1_git:%s" % unknown_content_["sha1_git"]) | ||||
▲ Show 20 Lines • Show All 518 Lines • ▼ Show 20 Lines | def test_lookup_content_not_found(): | ||||
assert e.match( | assert e.match( | ||||
"Content with %s checksum equals to %s not found!" | "Content with %s checksum equals to %s not found!" | ||||
% ("sha1", unknown_content_["sha1"]) | % ("sha1", unknown_content_["sha1"]) | ||||
) | ) | ||||
@given(content()) | @given(content()) | ||||
def test_lookup_content_with_sha1(archive_data, content): | def test_lookup_content_with_sha1(archive_data, content): | ||||
actual_content = service.lookup_content("sha1:%s" % content["sha1"]) | actual_content = service.lookup_content(f"sha1:{content['sha1']}") | ||||
expected_content = archive_data.content_get_metadata(content["sha1"]) | expected_content = archive_data.content_get(content["sha1"]) | ||||
assert actual_content == expected_content | assert actual_content == expected_content | ||||
@given(content()) | @given(content()) | ||||
def test_lookup_content_with_sha256(archive_data, content): | def test_lookup_content_with_sha256(archive_data, content): | ||||
actual_content = service.lookup_content("sha256:%s" % content["sha256"]) | actual_content = service.lookup_content(f"sha256:{content['sha256']}") | ||||
expected_content = archive_data.content_get_metadata(content["sha1"]) | expected_content = archive_data.content_get(content["sha1"]) | ||||
assert actual_content == expected_content | assert actual_content == expected_content | ||||
def test_lookup_directory_bad_checksum(): | def test_lookup_directory_bad_checksum(): | ||||
with pytest.raises(BadInputExc): | with pytest.raises(BadInputExc): | ||||
service.lookup_directory("directory_id") | service.lookup_directory("directory_id") | ||||
▲ Show 20 Lines • Show All 334 Lines • Show Last 20 Lines |