Use multiple objects in the test.

This is to ensure only the intended subset is deleted and not all
objects.
This commit is contained in:
Vincent Driessen 2010-12-13 13:24:20 -08:00
parent 5b118f64ec
commit 4d5164c580

View File

@ -744,13 +744,16 @@ class QuerySetTest(unittest.TestCase):
me = self.Person(name='Test User')
me.save()
someoneelse = self.Person(name='Some-one Else')
someoneelse.save()
post = BlogPost(content='Watching TV', author=me)
post.save()
BlogPost(content='Watching TV', author=me).save()
BlogPost(content='Chilling out', author=me).save()
BlogPost(content='Pro Testing', author=someoneelse).save()
self.assertEqual(3, BlogPost.objects.count())
self.Person.objects(name='Test User').delete()
self.assertEqual(1, BlogPost.objects.count())
self.Person.objects.delete()
self.assertEqual(0, BlogPost.objects.count())
def test_delete_rule_nullify(self):
"""Ensure nullification of references to deleted documents.