diff options
| author | michaldabski <contact@michaldabski.com> | 2017-06-15 21:44:20 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-06-26 18:12:35 -0400 |
| commit | d381914aef50e04ca44b9d7bb9274c8351f5b9bf (patch) | |
| tree | 22cb66be3571f5f4f20fa02efbdb93720b6c778c /tests/contenttypes_tests | |
| parent | 44a7b98abbec02f1a4f35662040f602fd616d0cd (diff) | |
Fixed #28313 -- Added model name max length check of 100 characters in contrib.contentttypes.
Diffstat (limited to 'tests/contenttypes_tests')
| -rw-r--r-- | tests/contenttypes_tests/test_checks.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/contenttypes_tests/test_checks.py b/tests/contenttypes_tests/test_checks.py index 6b33107de2..44cd3c2758 100644 --- a/tests/contenttypes_tests/test_checks.py +++ b/tests/contenttypes_tests/test_checks.py @@ -1,5 +1,6 @@ from unittest import mock +from django.contrib.contenttypes.checks import check_model_name_lengths from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) @@ -216,3 +217,20 @@ class GenericRelationTests(SimpleTestCase): id='fields.E001', ) ]) + + +@isolate_apps('contenttypes_tests', attr_name='apps') +class ModelCheckTests(SimpleTestCase): + def test_model_name_too_long(self): + model = type('A' * 101, (models.Model,), {'__module__': self.__module__}) + self.assertEqual(check_model_name_lengths(self.apps.get_app_configs()), [ + checks.Error( + 'Model names must be at most 100 characters (got 101).', + obj=model, + id='contenttypes.E005', + ) + ]) + + def test_model_name_max_length(self): + type('A' * 100, (models.Model,), {'__module__': self.__module__}) + self.assertEqual(check_model_name_lengths(self.apps.get_app_configs()), []) |
