Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_storage.py
Show First 20 Lines • Show All 3,221 Lines • ▼ Show 20 Lines | def test_content_find_bad_input(self, swh_storage): | ||||
# 1. with bad input | # 1. with bad input | ||||
with pytest.raises(StorageArgumentException): | with pytest.raises(StorageArgumentException): | ||||
swh_storage.content_find({}) # empty is bad | swh_storage.content_find({}) # empty is bad | ||||
# 2. with bad input | # 2. with bad input | ||||
with pytest.raises(StorageArgumentException): | with pytest.raises(StorageArgumentException): | ||||
swh_storage.content_find({"unknown-sha1": "something"}) # not the right key | swh_storage.content_find({"unknown-sha1": "something"}) # not the right key | ||||
def test_object_find_by_sha1_git(self, swh_storage): | def test_object_find_by_sha1_git(self, swh_storage, sample_data_model): | ||||
content = sample_data_model["content"][0] | |||||
directory = sample_data_model["directory"][0] | |||||
revision = sample_data_model["revision"][0] | |||||
release = sample_data_model["release"][0] | |||||
sha1_gits = [b"00000000000000000000"] | sha1_gits = [b"00000000000000000000"] | ||||
expected = { | expected = { | ||||
b"00000000000000000000": [], | b"00000000000000000000": [], | ||||
} | } | ||||
swh_storage.content_add([data.cont]) | swh_storage.content_add([content]) | ||||
sha1_gits.append(data.cont["sha1_git"]) | sha1_gits.append(content.sha1_git) | ||||
expected[data.cont["sha1_git"]] = [ | |||||
{"sha1_git": data.cont["sha1_git"], "type": "content",} | expected[content.sha1_git] = [ | ||||
{"sha1_git": content.sha1_git, "type": "content",} | |||||
] | ] | ||||
swh_storage.directory_add([data.dir]) | swh_storage.directory_add([directory]) | ||||
sha1_gits.append(data.dir["id"]) | sha1_gits.append(directory.id) | ||||
expected[data.dir["id"]] = [{"sha1_git": data.dir["id"], "type": "directory",}] | expected[directory.id] = [{"sha1_git": directory.id, "type": "directory",}] | ||||
swh_storage.revision_add([data.revision]) | swh_storage.revision_add([revision]) | ||||
sha1_gits.append(data.revision["id"]) | sha1_gits.append(revision.id) | ||||
expected[data.revision["id"]] = [ | expected[revision.id] = [{"sha1_git": revision.id, "type": "revision",}] | ||||
{"sha1_git": data.revision["id"], "type": "revision",} | |||||
] | |||||
swh_storage.release_add([data.release]) | swh_storage.release_add([release]) | ||||
sha1_gits.append(data.release["id"]) | sha1_gits.append(release.id) | ||||
expected[data.release["id"]] = [ | expected[release.id] = [{"sha1_git": release.id, "type": "release",}] | ||||
{"sha1_git": data.release["id"], "type": "release",} | |||||
] | |||||
ret = swh_storage.object_find_by_sha1_git(sha1_gits) | ret = swh_storage.object_find_by_sha1_git(sha1_gits) | ||||
assert expected == ret | assert expected == ret | ||||
def test_metadata_fetcher_add_get(self, swh_storage): | def test_metadata_fetcher_add_get(self, swh_storage): | ||||
actual_fetcher = swh_storage.metadata_fetcher_get( | actual_fetcher = swh_storage.metadata_fetcher_get( | ||||
data.metadata_fetcher.name, data.metadata_fetcher.version | data.metadata_fetcher.name, data.metadata_fetcher.version | ||||
▲ Show 20 Lines • Show All 1,025 Lines • Show Last 20 Lines |