mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
[1.1.X] Fixed #6191, #11296 -- Modified the admin deletion confirmation page to use the same object collection scheme as the actual deletion. This ensures that all objects that may be deleted are actually deleted, and that cyclic display problems are avoided. Thanks to carljm for the patch.
Backport of r12598 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12600 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
58
tests/regressiontests/admin_util/tests.py
Normal file
58
tests/regressiontests/admin_util/tests.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from django.contrib.admin.util import NestedObjects
|
||||
|
||||
from models import Count
|
||||
|
||||
|
||||
class NestedObjectsTests(TestCase):
|
||||
"""
|
||||
Tests for ``NestedObject`` utility collection.
|
||||
|
||||
"""
|
||||
def setUp(self):
|
||||
self.n = NestedObjects()
|
||||
self.objs = [Count.objects.create(num=i) for i in range(5)]
|
||||
|
||||
def _check(self, target):
|
||||
self.assertEquals(self.n.nested(lambda obj: obj.num), target)
|
||||
|
||||
def _add(self, obj, parent=None):
|
||||
# don't bother providing the extra args that NestedObjects ignores
|
||||
self.n.add(None, None, obj, None, parent)
|
||||
|
||||
def test_unrelated_roots(self):
|
||||
self._add(self.objs[0])
|
||||
self._add(self.objs[1])
|
||||
self._add(self.objs[2], self.objs[1])
|
||||
|
||||
self._check([0, 1, [2]])
|
||||
|
||||
def test_siblings(self):
|
||||
self._add(self.objs[0])
|
||||
self._add(self.objs[1], self.objs[0])
|
||||
self._add(self.objs[2], self.objs[0])
|
||||
|
||||
self._check([0, [1, 2]])
|
||||
|
||||
def test_duplicate_instances(self):
|
||||
self._add(self.objs[0])
|
||||
self._add(self.objs[1])
|
||||
dupe = Count.objects.get(num=1)
|
||||
self._add(dupe, self.objs[0])
|
||||
|
||||
self._check([0, 1])
|
||||
|
||||
def test_non_added_parent(self):
|
||||
self._add(self.objs[0], self.objs[1])
|
||||
|
||||
self._check([0])
|
||||
|
||||
def test_cyclic(self):
|
||||
self._add(self.objs[0], self.objs[2])
|
||||
self._add(self.objs[1], self.objs[0])
|
||||
self._add(self.objs[2], self.objs[1])
|
||||
self._add(self.objs[0], self.objs[2])
|
||||
|
||||
self._check([0, [1, [2]]])
|
||||
|
||||
Reference in New Issue
Block a user