2017-12-11 23:36:33 +08:00
|
|
|
from django.db import models
|
|
|
|
from django.test import SimpleTestCase
|
2017-07-13 19:55:23 +08:00
|
|
|
|
|
|
|
from .models import AutoModel, BigAutoModel, SmallAutoModel
|
2017-12-11 23:36:33 +08:00
|
|
|
from .test_integerfield import (
|
|
|
|
BigIntegerFieldTests, IntegerFieldTests, SmallIntegerFieldTests,
|
|
|
|
)
|
2017-07-13 19:55:23 +08:00
|
|
|
|
|
|
|
|
2017-12-11 23:36:33 +08:00
|
|
|
class AutoFieldTests(IntegerFieldTests):
|
2017-07-13 19:55:23 +08:00
|
|
|
model = AutoModel
|
2020-11-02 15:20:15 +08:00
|
|
|
rel_db_type_class = models.IntegerField
|
2017-07-13 19:55:23 +08:00
|
|
|
|
2017-12-11 23:36:33 +08:00
|
|
|
|
|
|
|
class BigAutoFieldTests(BigIntegerFieldTests):
|
2017-07-13 19:55:23 +08:00
|
|
|
model = BigAutoModel
|
2020-11-02 15:20:15 +08:00
|
|
|
rel_db_type_class = models.BigIntegerField
|
2017-07-13 19:55:23 +08:00
|
|
|
|
|
|
|
|
2017-12-11 23:36:33 +08:00
|
|
|
class SmallAutoFieldTests(SmallIntegerFieldTests):
|
2017-07-13 19:55:23 +08:00
|
|
|
model = SmallAutoModel
|
2020-11-02 15:20:15 +08:00
|
|
|
rel_db_type_class = models.SmallIntegerField
|
2017-12-11 23:36:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
class AutoFieldInheritanceTests(SimpleTestCase):
|
|
|
|
|
|
|
|
def test_isinstance_of_autofield(self):
|
|
|
|
for field in (models.BigAutoField, models.SmallAutoField):
|
|
|
|
with self.subTest(field.__name__):
|
|
|
|
self.assertIsInstance(field(), models.AutoField)
|
|
|
|
|
|
|
|
def test_issubclass_of_autofield(self):
|
|
|
|
for field in (models.BigAutoField, models.SmallAutoField):
|
|
|
|
with self.subTest(field.__name__):
|
|
|
|
self.assertTrue(issubclass(field, models.AutoField))
|