Fix assert_max_length schematics
This commit is contained in:
@@ -4,6 +4,12 @@ Changelog
|
|||||||
Here you can see the full list of changes between each SQLAlchemy-Utils release.
|
Here you can see the full list of changes between each SQLAlchemy-Utils release.
|
||||||
|
|
||||||
|
|
||||||
|
0.27.6 (2014-10-29)
|
||||||
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
- Fixed assert_max_length not working with non nullable columns
|
||||||
|
|
||||||
|
|
||||||
0.27.5 (2014-10-24)
|
0.27.5 (2014-10-24)
|
||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ def _expect_successful_update(obj, field, value, reraise_exc):
|
|||||||
|
|
||||||
def _expect_failing_update(obj, field, value, expected_exc):
|
def _expect_failing_update(obj, field, value, expected_exc):
|
||||||
with raises(expected_exc):
|
with raises(expected_exc):
|
||||||
_update_field(obj, field, None)
|
_update_field(obj, field, value)
|
||||||
session = sa.orm.object_session(obj)
|
session = sa.orm.object_session(obj)
|
||||||
session.rollback()
|
session.rollback()
|
||||||
|
|
||||||
|
@@ -31,13 +31,13 @@ class AssertionTestCase(TestCase):
|
|||||||
id = sa.Column(sa.Integer, primary_key=True)
|
id = sa.Column(sa.Integer, primary_key=True)
|
||||||
name = sa.Column(sa.String(20))
|
name = sa.Column(sa.String(20))
|
||||||
age = sa.Column(sa.Integer, nullable=False)
|
age = sa.Column(sa.Integer, nullable=False)
|
||||||
email = sa.Column(sa.String(200), unique=True)
|
email = sa.Column(sa.String(200), nullable=False, unique=True)
|
||||||
|
|
||||||
self.User = User
|
self.User = User
|
||||||
|
|
||||||
def setup_method(self, method):
|
def setup_method(self, method):
|
||||||
TestCase.setup_method(self, method)
|
TestCase.setup_method(self, method)
|
||||||
user = self.User(name='Someone', age=15)
|
user = self.User(name='Someone', email='someone@example.com', age=15)
|
||||||
self.session.add(user)
|
self.session.add(user)
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
self.user = user
|
self.user = user
|
||||||
@@ -73,6 +73,10 @@ class TestAssertMaxLength(AssertionTestCase):
|
|||||||
assert_max_length(self.user, 'name', 20)
|
assert_max_length(self.user, 'name', 20)
|
||||||
assert_max_length(self.user, 'name', 20)
|
assert_max_length(self.user, 'name', 20)
|
||||||
|
|
||||||
|
def test_with_non_nullable_column(self):
|
||||||
|
assert_max_length(self.user, 'email', 200)
|
||||||
|
assert_max_length(self.user, 'email', 200)
|
||||||
|
|
||||||
def test_smaller_than_max_length(self):
|
def test_smaller_than_max_length(self):
|
||||||
with raises(AssertionError):
|
with raises(AssertionError):
|
||||||
assert_max_length(self.user, 'name', 19)
|
assert_max_length(self.user, 'name', 19)
|
||||||
|
Reference in New Issue
Block a user