summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-07-15 11:07:43 -0400
committerTim Graham <timograham@gmail.com>2016-08-10 21:19:09 -0400
commite2dfa81ff7489d97700604d634adacf1384af184 (patch)
tree820b7dbbcf611b5f18e02375cc3e2d9dbea5ab98 /tests
parent7399fee6c3bb7eded1ecf5855d71520db299d79d (diff)
Refs #18682 -- Edited explanation in stale content type deletion.
Follow up to 8db889eaf7dce0cb715b075be32047c1b1b316da.
Diffstat (limited to 'tests')
-rw-r--r--tests/contenttypes_tests/models.py1
-rw-r--r--tests/contenttypes_tests/tests.py16
2 files changed, 12 insertions, 5 deletions
diff --git a/tests/contenttypes_tests/models.py b/tests/contenttypes_tests/models.py
index 4b9d3d31e6..fe1854e8a3 100644
--- a/tests/contenttypes_tests/models.py
+++ b/tests/contenttypes_tests/models.py
@@ -131,6 +131,7 @@ class Post(models.Model):
class ModelWithNullFKToSite(models.Model):
title = models.CharField(max_length=200)
site = models.ForeignKey(Site, null=True, on_delete=models.CASCADE)
+ post = models.ForeignKey(Post, null=True, on_delete=models.CASCADE)
def __str__(self):
return self.title
diff --git a/tests/contenttypes_tests/tests.py b/tests/contenttypes_tests/tests.py
index 5c8c675a4a..6d57a23355 100644
--- a/tests/contenttypes_tests/tests.py
+++ b/tests/contenttypes_tests/tests.py
@@ -389,21 +389,27 @@ class UpdateContentTypesTests(TestCase):
def test_interactive_true_with_dependent_objects(self):
"""
interactive mode of update_contenttypes() (the default) should delete
- stale contenttypes and warn of dependent objects
+ stale contenttypes and warn of dependent objects.
"""
- Post.objects.create(title='post', content_type=self.content_type)
+ post = Post.objects.create(title='post', content_type=self.content_type)
+ # A related object is needed to show that a custom collector with
+ # can_fast_delete=False is needed.
+ ModelWithNullFKToSite.objects.create(post=post)
contenttypes_management.input = lambda x: force_str("yes")
with captured_stdout() as stdout:
contenttypes_management.update_contenttypes(self.app_config)
self.assertEqual(Post.objects.count(), 0)
- self.assertIn("1 object of type contenttypes_tests.post:", stdout.getvalue())
- self.assertIn("Deleting stale content type", stdout.getvalue())
+ output = stdout.getvalue()
+ self.assertIn('- Content type for contenttypes_tests.Fake', output)
+ self.assertIn('- 1 contenttypes_tests.Post object(s)', output)
+ self.assertIn('- 1 contenttypes_tests.ModelWithNullFKToSite', output)
+ self.assertIn('Deleting stale content type', output)
self.assertEqual(ContentType.objects.count(), self.before_count)
def test_interactive_true_without_dependent_objects(self):
"""
interactive mode of update_contenttypes() (the default) should delete
- stale contenttypes and inform there are no dependent objects
+ stale contenttypes even if there aren't any dependent objects.
"""
contenttypes_management.input = lambda x: force_str("yes")
with captured_stdout() as stdout: