Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/tests/test_objstorage_pathslicing.py
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | def test_check_id_mismatch(self): | ||||
self.assertEqual( | self.assertEqual( | ||||
( | ( | ||||
"Corrupt object %s should have id " | "Corrupt object %s should have id " | ||||
"12ebb2d6c81395bcc5cab965bdff640110cb67ff" % obj_id.hex(), | "12ebb2d6c81395bcc5cab965bdff640110cb67ff" % obj_id.hex(), | ||||
), | ), | ||||
error.exception.args, | error.exception.args, | ||||
) | ) | ||||
def test_get_random_contents(self): | |||||
content, obj_id = self.hash_content(b"get_random_content") | |||||
self.storage.add(content, obj_id=obj_id) | |||||
random_contents = list(self.storage.get_random(1)) | |||||
self.assertEqual(1, len(random_contents)) | |||||
self.assertIn(obj_id, random_contents) | |||||
def test_iterate_from(self): | def test_iterate_from(self): | ||||
all_ids = [] | all_ids = [] | ||||
for i in range(100): | for i in range(100): | ||||
content, obj_id = self.hash_content(b"content %d" % i) | content, obj_id = self.hash_content(b"content %d" % i) | ||||
self.storage.add(content, obj_id=obj_id) | self.storage.add(content, obj_id=obj_id) | ||||
all_ids.append(obj_id) | all_ids.append(obj_id) | ||||
all_ids.sort() | all_ids.sort() | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |