Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/tests/test_objstorage_multiplexer.py
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | class TestMultiplexerObjStorage(ObjStorageTestFixture, unittest.TestCase): | ||||
def test_delete_present(self): | def test_delete_present(self): | ||||
self.storage_v1.allow_delete = True | self.storage_v1.allow_delete = True | ||||
self.storage_v2.allow_delete = True | self.storage_v2.allow_delete = True | ||||
super().test_delete_present() | super().test_delete_present() | ||||
def test_get_random_contents(self): | def test_get_random_contents(self): | ||||
content, obj_id = self.hash_content(b"get_random_content") | content, obj_id = self.hash_content(b"get_random_content") | ||||
self.storage.add(content) | self.storage.add(content, obj_id=obj_id) | ||||
random_contents = list(self.storage.get_random(1)) | random_contents = list(self.storage.get_random(1)) | ||||
self.assertEqual(1, len(random_contents)) | self.assertEqual(1, len(random_contents)) | ||||
self.assertIn(obj_id, random_contents) | self.assertIn(obj_id, random_contents) | ||||
def test_access_readonly(self): | def test_access_readonly(self): | ||||
# Add a content to the readonly storage | # Add a content to the readonly storage | ||||
content, obj_id = self.hash_content(b"content in read-only") | content, obj_id = self.hash_content(b"content in read-only") | ||||
self.storage_v1.add(content) | self.storage_v1.add(content, obj_id=obj_id) | ||||
# Try to retrieve it on the main storage | # Try to retrieve it on the main storage | ||||
self.assertIn(obj_id, self.storage) | self.assertIn(obj_id, self.storage) |