Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/common/test_service.py
Show First 20 Lines • Show All 466 Lines • ▼ Show 20 Lines | |||||
): | ): | ||||
rev_data = archive_data.revision_get(revision) | rev_data = archive_data.revision_get(revision) | ||||
dir_entries = [ | dir_entries = [ | ||||
e | e | ||||
for e in archive_data.directory_ls(rev_data["directory"]) | for e in archive_data.directory_ls(rev_data["directory"]) | ||||
if e["type"] == "file" | if e["type"] == "file" | ||||
] | ] | ||||
expected_dir_entry = random.choice(dir_entries) | expected_dir_entry = random.choice(dir_entries) | ||||
expected_data = archive_data.content_get(expected_dir_entry["checksums"]["sha1"]) | expected_data = archive_data.content_get_data( | ||||
expected_dir_entry["checksums"]["sha1"] | |||||
) | |||||
actual_dir_entry = service.lookup_directory_with_revision( | actual_dir_entry = service.lookup_directory_with_revision( | ||||
revision, expected_dir_entry["name"], with_data=True | revision, expected_dir_entry["name"], with_data=True | ||||
) | ) | ||||
assert actual_dir_entry["type"] == expected_dir_entry["type"] | assert actual_dir_entry["type"] == expected_dir_entry["type"] | ||||
assert actual_dir_entry["revision"] == revision | assert actual_dir_entry["revision"] == revision | ||||
assert actual_dir_entry["path"] == expected_dir_entry["name"] | assert actual_dir_entry["path"] == expected_dir_entry["name"] | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | assert e.match( | ||||
% ("sha1", unknown_content_["sha1"]) | % ("sha1", unknown_content_["sha1"]) | ||||
) | ) | ||||
@given(content()) | @given(content()) | ||||
def test_lookup_content_raw(archive_data, content): | def test_lookup_content_raw(archive_data, content): | ||||
actual_content = service.lookup_content_raw("sha256:%s" % content["sha256"]) | actual_content = service.lookup_content_raw("sha256:%s" % content["sha256"]) | ||||
expected_content = archive_data.content_get(content["sha1"]) | expected_content = archive_data.content_get_data(content["sha1"]) | ||||
assert actual_content == expected_content | assert actual_content == expected_content | ||||
def test_lookup_content_not_found(): | def test_lookup_content_not_found(): | ||||
unknown_content_ = random_content() | unknown_content_ = random_content() | ||||
with pytest.raises(NotFoundExc) as e: | with pytest.raises(NotFoundExc) as e: | ||||
▲ Show 20 Lines • Show All 364 Lines • Show Last 20 Lines |