Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/tests/objstorage_testing.py
Show All 17 Lines | def hash_content(self, content): | ||||
obj_id = hashutil.hashdata(content)['sha1'] | obj_id = hashutil.hashdata(content)['sha1'] | ||||
return content, obj_id | return content, obj_id | ||||
def assertContentMatch(self, obj_id, expected_content): | def assertContentMatch(self, obj_id, expected_content): | ||||
content = self.storage.get(obj_id) | content = self.storage.get(obj_id) | ||||
self.assertEqual(content, expected_content) | self.assertEqual(content, expected_content) | ||||
@istest | @istest | ||||
def contains(self): | |||||
content_p, obj_id_p = self.hash_content(b'contains_present') | |||||
content_m, obj_id_m = self.hash_content(b'contains_missing') | |||||
self.storage.add(content_p, obj_id=obj_id_p) | |||||
self.assertIn(obj_id_p, self.storage) | |||||
self.assertNotIn(obj_id_m, self.storage) | |||||
@istest | |||||
def add_get_w_id(self): | def add_get_w_id(self): | ||||
content, obj_id = self.hash_content(b'add_get_w_id') | content, obj_id = self.hash_content(b'add_get_w_id') | ||||
r = self.storage.add(content, obj_id=obj_id) | r = self.storage.add(content, obj_id=obj_id) | ||||
self.assertEqual(obj_id, r) | self.assertEqual(obj_id, r) | ||||
self.assertContentMatch(obj_id, content) | self.assertContentMatch(obj_id, content) | ||||
@istest | @istest | ||||
def add_get_wo_id(self): | def add_get_wo_id(self): | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |