Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/archive/tests/test_archive.py
Show First 20 Lines • Show All 359 Lines • ▼ Show 20 Lines | def test_archive_extid(): | ||||
for manifest_format, expected_manifest in [ | for manifest_format, expected_manifest in [ | ||||
(string.Template("$a $b"), b"1 2"), | (string.Template("$a $b"), b"1 2"), | ||||
(string.Template(""), b""), | (string.Template(""), b""), | ||||
(None, "{time} {length} {version} {url}".format(**metadata).encode()), | (None, "{time} {length} {version} {url}".format(**metadata).encode()), | ||||
]: | ]: | ||||
actual_id = p_info.extid(manifest_format=manifest_format) | actual_id = p_info.extid(manifest_format=manifest_format) | ||||
assert actual_id == ( | assert actual_id == ( | ||||
"package-manifest-sha256", | "package-manifest-sha256", | ||||
0, | |||||
hashlib.sha256(expected_manifest).digest(), | hashlib.sha256(expected_manifest).digest(), | ||||
) | ) | ||||
with pytest.raises(KeyError): | with pytest.raises(KeyError): | ||||
p_info.extid(manifest_format=string.Template("$a $unknown_key")) | p_info.extid(manifest_format=string.Template("$a $unknown_key")) | ||||
def test_archive_snapshot_append(swh_storage, requests_mock_datadir): | def test_archive_snapshot_append(swh_storage, requests_mock_datadir): | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |