def test_get_with_previous_store(self): obj_store = ObjectStore(indexes=['type1:index1', 'type1:index2']) self._test_set_and_lookup(obj_store) new_obj_store = ObjectStore(prevstore=obj_store) self.assertEqual(new_obj_store.get(self.names[765]), self.values[765], "Get from previous store")
def test_update(self): obj1 = {'object-type': 'type1', 'index1': self.index1s[126], 'index2': self.index2s[126], 'count': 5} obj2 = {'object-type': 'type1', 'index1': self.index1s[126], 'index2': self.index2s[126], 'count': 8} obj_store = ObjectStore(indexes=['type1:index1', 'type1:index2']) obj_store.set('obj1', obj1) obj_store.set('obj1', obj2) self.assertEqual(obj_store.lookup('type1:index1', self.index1s[126]), obj2, "Lookup on index of updated value will find" "updated value") self.assertEqual(obj_store.get('obj1'), obj2, ".get will also get us the updated value")
def test_late_indexing_update(self): obj1 = {'object-type': 'type1', 'index1': self.index1s[126], 'index2': self.index2s[126], 'name': 'obj1'} obj2 = {'object-type': 'type1', 'index1': self.index1s[126], 'index2': self.index2s[126], 'name': 'obj1'} obj_store = ObjectStore() obj_store.set('obj1', obj1) obj_store.set('obj1', obj2) self.assertEqual(obj_store.lookup('type1:index2', self.index2s[126]), obj2, "Late indexing will provide us with the " "updated value") self.assertEqual(obj_store.get('obj1'), obj2, ".get will also get us the updated value")