Add tests for has_changes
This commit is contained in:
24
tests/functions/test_has_changes.py
Normal file
24
tests/functions/test_has_changes.py
Normal 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')
|
Reference in New Issue
Block a user