Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_storage.py
Show First 20 Lines • Show All 2,743 Lines • ▼ Show 20 Lines | def test_snapshot_add_get_filtered_and_paginated(self, swh_storage): | ||||
expected_snapshot = { | expected_snapshot = { | ||||
"id": snp_id, | "id": snp_id, | ||||
"branches": {branch_names[dir_idx]: branches[branch_names[dir_idx]],}, | "branches": {branch_names[dir_idx]: branches[branch_names[dir_idx]],}, | ||||
"next_branch": b"release", | "next_branch": b"release", | ||||
} | } | ||||
assert snapshot == expected_snapshot | assert snapshot == expected_snapshot | ||||
def test_snapshot_add_get_branch_by_type(self, swh_storage): | |||||
snapshot = copy.deepcopy(data.complete_snapshot) | |||||
alias1 = b"alias1" | |||||
alias2 = b"alias2" | |||||
target1 = random.choice(list(snapshot["branches"].keys())) | |||||
target2 = random.choice(list(snapshot["branches"].keys())) | |||||
snapshot["branches"][alias2] = { | |||||
"target": target2, | |||||
"target_type": "alias", | |||||
} | |||||
snapshot["branches"][alias1] = { | |||||
"target": target1, | |||||
"target_type": "alias", | |||||
} | |||||
swh_storage.snapshot_add([snapshot]) | |||||
branches = swh_storage.snapshot_get_branches( | |||||
snapshot["id"], | |||||
target_types=["alias"], | |||||
branches_from=alias1, | |||||
branches_count=1, | |||||
)["branches"] | |||||
assert len(branches) == 1 | |||||
assert alias1 in branches | |||||
def test_snapshot_add_get(self, swh_storage): | def test_snapshot_add_get(self, swh_storage): | ||||
origin_url = swh_storage.origin_add_one(data.origin) | origin_url = swh_storage.origin_add_one(data.origin) | ||||
visit = OriginVisit( | visit = OriginVisit( | ||||
origin=origin_url, date=data.date_visit1, type=data.type_visit1, | origin=origin_url, date=data.date_visit1, type=data.type_visit1, | ||||
) | ) | ||||
origin_visit1 = swh_storage.origin_visit_add([visit])[0] | origin_visit1 = swh_storage.origin_visit_add([visit])[0] | ||||
visit_id = origin_visit1.visit | visit_id = origin_visit1.visit | ||||
▲ Show 20 Lines • Show All 1,406 Lines • Show Last 20 Lines |