def create_activity(self, object=None, target=None): activity = versioning_manager.activity_cls( object=object, target=target, verb=u'create', ) self.session.add(activity) return activity
def test_delete_activity(self): article = self.create_article() self.create_activity(article) self.session.commit() self.session.delete(article) activity = versioning_manager.activity_cls( object=article, verb=u'delete', ) self.session.add(activity) self.session.commit() versions = (self.session.query(self.ArticleVersion).order_by( sa.desc(self.ArticleVersion.transaction_id)).all()) assert activity assert activity.transaction_id assert activity.object is None assert activity.object_version == versions[-1]
def test_delete_activity(self): article = self.create_article() self.create_activity(article) self.session.commit() self.session.delete(article) activity = versioning_manager.activity_cls( object=article, verb=u'delete', ) self.session.add(activity) self.session.commit() versions = ( self.session.query(self.ArticleVersion) .order_by(sa.desc(self.ArticleVersion.transaction_id)) .all() ) assert activity assert activity.transaction_id assert activity.object is None assert activity.object_version == versions[-1]
def test_activity_target(self): article = self.create_article() self.create_activity(article) self.session.commit() tag = self.Tag(name=u'some tag', article=article) self.session.add(tag) self.session.flush() activity = versioning_manager.activity_cls( object=tag, target=article, verb=u'create', ) self.session.add(activity) self.session.commit() activity = self.session.query( versioning_manager.activity_cls).filter_by(id=activity.id).one() assert activity assert activity.transaction_id assert activity.object == tag assert activity.object_version == tag.versions[-1] assert activity.target == article assert activity.target_version == article.versions[-1]
def test_activity_target(self): article = self.create_article() self.create_activity(article) self.session.commit() tag = self.Tag(name=u'some tag', article=article) self.session.add(tag) self.session.flush() activity = versioning_manager.activity_cls( object=tag, target=article, verb=u'create', ) self.session.add(activity) self.session.commit() activity = self.session.query( versioning_manager.activity_cls ).filter_by(id=activity.id).one() assert activity assert activity.transaction_id assert activity.object == tag assert activity.object_version == tag.versions[-1] assert activity.target == article assert activity.target_version == article.versions[-1]