-
-
Notifications
You must be signed in to change notification settings - Fork 427
add range validation #1887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
add range validation #1887
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from tests import testmodels | ||
from tortoise.contrib import test | ||
from tortoise.exceptions import IntegrityError | ||
from tortoise.exceptions import IntegrityError, ValidationError | ||
from tortoise.expressions import F | ||
|
||
|
||
|
@@ -38,6 +38,13 @@ async def test_min(self): | |
obj2 = await testmodels.IntFields.get(id=obj.id) | ||
self.assertEqual(obj, obj2) | ||
|
||
with self.assertRaises(ValidationError): | ||
await testmodels.IntFields.create(intnum=-2147483649) | ||
|
||
async def test_max(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
with self.assertRaises(ValidationError): | ||
await testmodels.IntFields.create(intnum=2147483648) | ||
|
||
async def test_cast(self): | ||
obj0 = await testmodels.IntFields.create(intnum="3") | ||
obj = await testmodels.IntFields.get(id=obj0.id) | ||
|
@@ -83,6 +90,13 @@ async def test_min(self): | |
obj2 = await testmodels.SmallIntFields.get(id=obj.id) | ||
self.assertEqual(obj, obj2) | ||
|
||
with self.assertRaises(ValidationError): | ||
await testmodels.SmallIntFields.create(smallintnum=-32769) | ||
|
||
async def test_max(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
with self.assertRaises(ValidationError): | ||
await testmodels.SmallIntFields.create(smallintnum=32768) | ||
|
||
async def test_values(self): | ||
obj0 = await testmodels.SmallIntFields.create(smallintnum=2) | ||
values = await testmodels.SmallIntFields.get(id=obj0.id).values("smallintnum") | ||
|
@@ -125,6 +139,13 @@ async def test_min(self): | |
obj2 = await testmodels.BigIntFields.get(id=obj.id) | ||
self.assertEqual(obj, obj2) | ||
|
||
with self.assertRaises(ValidationError): | ||
await testmodels.BigIntFields.create(intnum=-9223372036854775809) | ||
|
||
async def test_max(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
with self.assertRaises(ValidationError): | ||
await testmodels.BigIntFields.create(intnum=9223372036854775808) | ||
|
||
async def test_cast(self): | ||
obj0 = await testmodels.BigIntFields.create(intnum="3") | ||
obj = await testmodels.BigIntFields.get(id=obj0.id) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please mention this PR in CHANGELOG?