Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/common/test_service.py
Show First 20 Lines • Show All 895 Lines • ▼ Show 20 Lines | |||||
def test_lookup_missing_hashes_non_present(): | def test_lookup_missing_hashes_non_present(): | ||||
missing_cnt = random_sha1() | missing_cnt = random_sha1() | ||||
missing_dir = random_sha1() | missing_dir = random_sha1() | ||||
missing_rev = random_sha1() | missing_rev = random_sha1() | ||||
missing_rel = random_sha1() | missing_rel = random_sha1() | ||||
missing_snp = random_sha1() | missing_snp = random_sha1() | ||||
grouped_pids = { | grouped_swhids = { | ||||
CONTENT: [hash_to_bytes(missing_cnt)], | CONTENT: [hash_to_bytes(missing_cnt)], | ||||
DIRECTORY: [hash_to_bytes(missing_dir)], | DIRECTORY: [hash_to_bytes(missing_dir)], | ||||
REVISION: [hash_to_bytes(missing_rev)], | REVISION: [hash_to_bytes(missing_rev)], | ||||
RELEASE: [hash_to_bytes(missing_rel)], | RELEASE: [hash_to_bytes(missing_rel)], | ||||
SNAPSHOT: [hash_to_bytes(missing_snp)], | SNAPSHOT: [hash_to_bytes(missing_snp)], | ||||
} | } | ||||
actual_result = service.lookup_missing_hashes(grouped_pids) | actual_result = service.lookup_missing_hashes(grouped_swhids) | ||||
assert actual_result == { | assert actual_result == { | ||||
missing_cnt, | missing_cnt, | ||||
missing_dir, | missing_dir, | ||||
missing_rev, | missing_rev, | ||||
missing_rel, | missing_rel, | ||||
missing_snp, | missing_snp, | ||||
} | } | ||||
@given(content(), directory()) | @given(content(), directory()) | ||||
def test_lookup_missing_hashes_some_present(archive_data, content, directory): | def test_lookup_missing_hashes_some_present(archive_data, content, directory): | ||||
missing_rev = random_sha1() | missing_rev = random_sha1() | ||||
missing_rel = random_sha1() | missing_rel = random_sha1() | ||||
missing_snp = random_sha1() | missing_snp = random_sha1() | ||||
grouped_pids = { | grouped_swhids = { | ||||
CONTENT: [hash_to_bytes(content["sha1_git"])], | CONTENT: [hash_to_bytes(content["sha1_git"])], | ||||
DIRECTORY: [hash_to_bytes(directory)], | DIRECTORY: [hash_to_bytes(directory)], | ||||
REVISION: [hash_to_bytes(missing_rev)], | REVISION: [hash_to_bytes(missing_rev)], | ||||
RELEASE: [hash_to_bytes(missing_rel)], | RELEASE: [hash_to_bytes(missing_rel)], | ||||
SNAPSHOT: [hash_to_bytes(missing_snp)], | SNAPSHOT: [hash_to_bytes(missing_snp)], | ||||
} | } | ||||
actual_result = service.lookup_missing_hashes(grouped_pids) | actual_result = service.lookup_missing_hashes(grouped_swhids) | ||||
assert actual_result == {missing_rev, missing_rel, missing_snp} | assert actual_result == {missing_rev, missing_rel, missing_snp} | ||||
@given(origin()) | @given(origin()) | ||||
def test_lookup_origin_extra_trailing_slash(origin): | def test_lookup_origin_extra_trailing_slash(origin): | ||||
origin_info = service.lookup_origin({"url": f"{origin['url']}/"}) | origin_info = service.lookup_origin({"url": f"{origin['url']}/"}) | ||||
assert origin_info["url"] == origin["url"] | assert origin_info["url"] == origin["url"] | ||||
Show All 28 Lines |