mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
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):
|
class AutoFieldTests(IntegerFieldTests):
|
||||||
model = AutoModel
|
model = AutoModel
|
||||||
|
rel_db_type_class = models.IntegerField
|
||||||
|
|
||||||
|
|
||||||
class BigAutoFieldTests(BigIntegerFieldTests):
|
class BigAutoFieldTests(BigIntegerFieldTests):
|
||||||
model = BigAutoModel
|
model = BigAutoModel
|
||||||
|
rel_db_type_class = models.BigIntegerField
|
||||||
|
|
||||||
|
|
||||||
class SmallAutoFieldTests(SmallIntegerFieldTests):
|
class SmallAutoFieldTests(SmallIntegerFieldTests):
|
||||||
model = SmallAutoModel
|
model = SmallAutoModel
|
||||||
|
rel_db_type_class = models.SmallIntegerField
|
||||||
|
|
||||||
|
|
||||||
class AutoFieldInheritanceTests(SimpleTestCase):
|
class AutoFieldInheritanceTests(SimpleTestCase):
|
||||||
|
@ -14,6 +14,7 @@ from .models import (
|
|||||||
class IntegerFieldTests(TestCase):
|
class IntegerFieldTests(TestCase):
|
||||||
model = IntegerModel
|
model = IntegerModel
|
||||||
documented_range = (-2147483648, 2147483647)
|
documented_range = (-2147483648, 2147483647)
|
||||||
|
rel_db_type_class = models.IntegerField
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def backend_range(self):
|
def backend_range(self):
|
||||||
@ -154,15 +155,22 @@ class IntegerFieldTests(TestCase):
|
|||||||
with self.assertRaisesMessage(exception, msg):
|
with self.assertRaisesMessage(exception, msg):
|
||||||
self.model.objects.create(value=value)
|
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):
|
class SmallIntegerFieldTests(IntegerFieldTests):
|
||||||
model = SmallIntegerModel
|
model = SmallIntegerModel
|
||||||
documented_range = (-32768, 32767)
|
documented_range = (-32768, 32767)
|
||||||
|
rel_db_type_class = models.SmallIntegerField
|
||||||
|
|
||||||
|
|
||||||
class BigIntegerFieldTests(IntegerFieldTests):
|
class BigIntegerFieldTests(IntegerFieldTests):
|
||||||
model = BigIntegerModel
|
model = BigIntegerModel
|
||||||
documented_range = (-9223372036854775808, 9223372036854775807)
|
documented_range = (-9223372036854775808, 9223372036854775807)
|
||||||
|
rel_db_type_class = models.BigIntegerField
|
||||||
|
|
||||||
|
|
||||||
class PositiveSmallIntegerFieldTests(IntegerFieldTests):
|
class PositiveSmallIntegerFieldTests(IntegerFieldTests):
|
||||||
@ -173,6 +181,11 @@ class PositiveSmallIntegerFieldTests(IntegerFieldTests):
|
|||||||
class PositiveIntegerFieldTests(IntegerFieldTests):
|
class PositiveIntegerFieldTests(IntegerFieldTests):
|
||||||
model = PositiveIntegerModel
|
model = PositiveIntegerModel
|
||||||
documented_range = (0, 2147483647)
|
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.")
|
@unittest.skipIf(connection.vendor == 'sqlite', "SQLite doesn't have a constraint.")
|
||||||
def test_negative_values(self):
|
def test_negative_values(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user