Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_storage.py
Show First 20 Lines • Show All 1,222 Lines • ▼ Show 20 Lines | def test_snapshot_add_get_paginated(self): | ||||
rel_idx = branch_names.index(b'release') | rel_idx = branch_names.index(b'release') | ||||
expected_snapshot = { | expected_snapshot = { | ||||
'id': snp_id, | 'id': snp_id, | ||||
'branches': { | 'branches': { | ||||
name: branches[name] | name: branches[name] | ||||
for name in branch_names[rel_idx:] | for name in branch_names[rel_idx:] | ||||
}, | }, | ||||
'next_branch': None, | |||||
} | } | ||||
self.assertEqual(snapshot, expected_snapshot) | self.assertEqual(snapshot, expected_snapshot) | ||||
snapshot = self.storage.snapshot_get_branches(snp_id, | snapshot = self.storage.snapshot_get_branches(snp_id, | ||||
branches_count=1) | branches_count=1) | ||||
expected_snapshot = { | expected_snapshot = { | ||||
'id': snp_id, | 'id': snp_id, | ||||
'branches': { | 'branches': { | ||||
branch_names[0]: branches[branch_names[0]], | branch_names[0]: branches[branch_names[0]], | ||||
}, | }, | ||||
'next_branch': b'content', | |||||
} | } | ||||
self.assertEqual(snapshot, expected_snapshot) | self.assertEqual(snapshot, expected_snapshot) | ||||
snapshot = self.storage.snapshot_get_branches( | snapshot = self.storage.snapshot_get_branches( | ||||
snp_id, branches_from=b'directory', branches_count=3) | snp_id, branches_from=b'directory', branches_count=3) | ||||
dir_idx = branch_names.index(b'directory') | dir_idx = branch_names.index(b'directory') | ||||
expected_snapshot = { | expected_snapshot = { | ||||
'id': snp_id, | 'id': snp_id, | ||||
'branches': { | 'branches': { | ||||
name: branches[name] | name: branches[name] | ||||
for name in branch_names[dir_idx:dir_idx + 3] | for name in branch_names[dir_idx:dir_idx + 3] | ||||
}, | }, | ||||
'next_branch': branch_names[dir_idx + 3], | |||||
} | } | ||||
self.assertEqual(snapshot, expected_snapshot) | self.assertEqual(snapshot, expected_snapshot) | ||||
def test_snapshot_add_get_filtered(self): | def test_snapshot_add_get_filtered(self): | ||||
origin_id = self.storage.origin_add_one(self.origin) | origin_id = self.storage.origin_add_one(self.origin) | ||||
origin_visit1 = self.storage.origin_visit_add(origin_id, | origin_visit1 = self.storage.origin_visit_add(origin_id, | ||||
self.date_visit1) | self.date_visit1) | ||||
Show All 9 Lines | def test_snapshot_add_get_filtered(self): | ||||
expected_snapshot = { | expected_snapshot = { | ||||
'id': snp_id, | 'id': snp_id, | ||||
'branches': { | 'branches': { | ||||
name: tgt | name: tgt | ||||
for name, tgt in branches.items() | for name, tgt in branches.items() | ||||
if tgt and tgt['target_type'] in ['release', 'revision'] | if tgt and tgt['target_type'] in ['release', 'revision'] | ||||
}, | }, | ||||
'next_branch': None, | |||||
} | } | ||||
self.assertEqual(snapshot, expected_snapshot) | self.assertEqual(snapshot, expected_snapshot) | ||||
snapshot = self.storage.snapshot_get_branches(snp_id, | snapshot = self.storage.snapshot_get_branches(snp_id, | ||||
target_types=['alias']) | target_types=['alias']) | ||||
expected_snapshot = { | expected_snapshot = { | ||||
'id': snp_id, | 'id': snp_id, | ||||
'branches': { | 'branches': { | ||||
name: tgt | name: tgt | ||||
for name, tgt in branches.items() | for name, tgt in branches.items() | ||||
if tgt and tgt['target_type'] == 'alias' | if tgt and tgt['target_type'] == 'alias' | ||||
}, | }, | ||||
'next_branch': None, | |||||
} | } | ||||
self.assertEqual(snapshot, expected_snapshot) | self.assertEqual(snapshot, expected_snapshot) | ||||
def test_snapshot_add_get(self): | def test_snapshot_add_get(self): | ||||
origin_id = self.storage.origin_add_one(self.origin) | origin_id = self.storage.origin_add_one(self.origin) | ||||
origin_visit1 = self.storage.origin_visit_add(origin_id, | origin_visit1 = self.storage.origin_visit_add(origin_id, | ||||
self.date_visit1) | self.date_visit1) | ||||
▲ Show 20 Lines • Show All 675 Lines • Show Last 20 Lines |