mirror of https://github.com/django/django.git
Refs #32132 -- Added rel_db_type() tests for auto and integer fields.
This commit is contained in:
parent
d1791539a7
commit
4ebd633350
|
@ -9,14 +9,17 @@ from .test_integerfield import (
|
|||
|
||||
class AutoFieldTests(IntegerFieldTests):
|
||||
model = AutoModel
|
||||
rel_db_type_class = models.IntegerField
|
||||
|
||||
|
||||
class BigAutoFieldTests(BigIntegerFieldTests):
|
||||
model = BigAutoModel
|
||||
rel_db_type_class = models.BigIntegerField
|
||||
|
||||
|
||||
class SmallAutoFieldTests(SmallIntegerFieldTests):
|
||||
model = SmallAutoModel
|
||||
rel_db_type_class = models.SmallIntegerField
|
||||
|
||||
|
||||
class AutoFieldInheritanceTests(SimpleTestCase):
|
||||
|
|
|
@ -14,6 +14,7 @@ from .models import (
|
|||
class IntegerFieldTests(TestCase):
|
||||
model = IntegerModel
|
||||
documented_range = (-2147483648, 2147483647)
|
||||
rel_db_type_class = models.IntegerField
|
||||
|
||||
@property
|
||||
def backend_range(self):
|
||||
|
@ -154,15 +155,22 @@ class IntegerFieldTests(TestCase):
|
|||
with self.assertRaisesMessage(exception, msg):
|
||||
self.model.objects.create(value=value)
|
||||
|
||||
def test_rel_db_type(self):
|
||||
field = self.model._meta.get_field('value')
|
||||
rel_db_type = field.rel_db_type(connection)
|
||||
self.assertEqual(rel_db_type, self.rel_db_type_class().db_type(connection))
|
||||
|
||||
|
||||
class SmallIntegerFieldTests(IntegerFieldTests):
|
||||
model = SmallIntegerModel
|
||||
documented_range = (-32768, 32767)
|
||||
rel_db_type_class = models.SmallIntegerField
|
||||
|
||||
|
||||
class BigIntegerFieldTests(IntegerFieldTests):
|
||||
model = BigIntegerModel
|
||||
documented_range = (-9223372036854775808, 9223372036854775807)
|
||||
rel_db_type_class = models.BigIntegerField
|
||||
|
||||
|
||||
class PositiveSmallIntegerFieldTests(IntegerFieldTests):
|
||||
|
@ -173,6 +181,11 @@ class PositiveSmallIntegerFieldTests(IntegerFieldTests):
|
|||
class PositiveIntegerFieldTests(IntegerFieldTests):
|
||||
model = PositiveIntegerModel
|
||||
documented_range = (0, 2147483647)
|
||||
rel_db_type_class = (
|
||||
models.PositiveIntegerField
|
||||
if connection.features.related_fields_match_type
|
||||
else models.IntegerField
|
||||
)
|
||||
|
||||
@unittest.skipIf(connection.vendor == 'sqlite', "SQLite doesn't have a constraint.")
|
||||
def test_negative_values(self):
|
||||
|
|
Loading…
Reference in New Issue