Add tests for has_changes

This commit is contained in:
Konsta Vesterinen
2014-06-25 14:48:53 +03:00
parent 80b929463a
commit d03254daba

View File

@@ -0,0 +1,24 @@
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_utils import has_changes
class TestHasChanges(object):
def setup_method(self, method):
Base = declarative_base()
class Article(Base):
__tablename__ = 'article_translation'
id = sa.Column(sa.Integer, primary_key=True)
title = sa.Column(sa.String(100))
self.Article = Article
def test_without_changed_attr(self):
article = self.Article()
assert not has_changes(article, 'title')
def test_with_changed_attr(self):
article = self.Article(title='Some title')
assert has_changes(article, 'title')