Ticket #29387: 29387-regression-test.patch

File 29387-regression-test.patch, 1.3 KB (added by Carlton Gibson, 7 years ago)

Regression test — already passes

  • tests/generic_relations/tests.py

    diff --git a/tests/generic_relations/tests.py b/tests/generic_relations/tests.py
    index 4c27b6f3d5..2e8a41cde3 100644
    a b class ProxyRelatedModelTest(TestCase):  
    570570        newrel = ConcreteRelatedModel.objects.get(pk=newrel.pk)
    571571        self.assertEqual(base, newrel.bases.get())
    572572
     573    def test_deletion_cascade(self):
     574        """
     575        Regression for #29387: deletion does not cascase for proxy models.
     576
     577        !!!: PASSES — cannot reproduce.
     578        """
     579        # Concrete case
     580        concrete_obj = ConcreteRelatedModel.objects.create()
     581        base = ForProxyModelModel.objects.create(obj=concrete_obj)
     582
     583        self.assertTrue(ForProxyModelModel.objects.filter(id=base.id).exists())
     584        concrete_obj.delete()
     585        self.assertFalse(ForProxyModelModel.objects.filter(id=base.id).exists())
     586
     587        # Proxy case — should fail (but does not)
     588        proxy_obj = ProxyRelatedModel.objects.create()
     589        base = ForProxyModelModel.objects.create(obj=proxy_obj)
     590
     591        self.assertTrue(ForProxyModelModel.objects.filter(id=base.id).exists())
     592        proxy_obj.delete()
     593        self.assertFalse(ForProxyModelModel.objects.filter(id=base.id).exists())
     594
    573595
    574596class TestInitWithNoneArgument(SimpleTestCase):
    575597
Back to Top