summaryrefslogtreecommitdiff
path: root/tests/invalid_models_tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-04-22 12:59:41 -0400
committerTim Graham <timograham@gmail.com>2016-04-22 12:59:41 -0400
commit87338198e921d944cc241e59c827bb9dffef728b (patch)
tree2b5abfd97e35159c20ad16b9ca38b106f885ac63 /tests/invalid_models_tests
parent9e4e20a71c9648f8a1c6397ada40739d4aaa3ec6 (diff)
Fixed #26320 -- Deprecated implicit OneToOnField parent_link.
Diffstat (limited to 'tests/invalid_models_tests')
-rw-r--r--tests/invalid_models_tests/test_models.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
index e4b3105574..b8f15cae60 100644
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -2,6 +2,7 @@
from __future__ import unicode_literals
import unittest
+import warnings
from django.conf import settings
from django.core.checks import Error
@@ -739,3 +740,24 @@ class OtherModelTests(SimpleTestCase):
)
]
self.assertEqual(errors, expected)
+
+ def test_missing_parent_link(self):
+ with warnings.catch_warnings(record=True) as warns:
+ warnings.simplefilter('always')
+
+ class Place(models.Model):
+ pass
+
+ class ParkingLot(Place):
+ # In lieu of any other connector, an existing OneToOneField will be
+ # promoted to the primary key.
+ parent = models.OneToOneField(Place, models.CASCADE)
+
+ self.assertEqual(len(warns), 1)
+ msg = str(warns[0].message)
+ self.assertEqual(
+ msg,
+ 'Add parent_link=True to invalid_models_tests.ParkingLot.parent '
+ 'as an implicit link is deprecated.'
+ )
+ self.assertEqual(ParkingLot._meta.pk.name, 'parent')