def _add_changeobj(self, collection_name, _id, data, operation_type): change = ChangeObject() object_id = [collection_name, _id] change.object_id = object_id change.data = data change.operation_type = operation_type change.changeset = self.changeset change.save()
def test_02(self): co = ChangeObject() objectid = (u'package', 1, 2, 3) co.object_id = objectid co.operation = ChangeObject.OperationType.CREATE co.data = json.dumps({ 'field1': 'aaaaaa', 'field2': 'bbbbbb' }, sort_keys=True) cs = Changeset() cs.manifest.append(co) cs.author = 'xyz' cs.save() changeobjs = list(ChangeObject.find()) assert len(changeobjs) == 1 co = changeobjs[0] assert co.changeset.id == cs.id out = Changeset.by_id(cs.id) assert len(out.manifest) == 1 assert out.manifest[0].object_id == co.object_id
def _find_changeobject(self, collection, _id): return ChangeObject.find_one({'object_id': [collection, _id]})