Ticket #25505: 25505-reproduced-issue.diff

File 25505-reproduced-issue.diff, 1.9 KB (added by Simon Charette, 8 years ago)

Integrated test case

  • tests/proxy_model_inheritance/models.py

    diff --git a/tests/proxy_model_inheritance/models.py b/tests/proxy_model_inheritance/models.py
    index 7a10b77..240fd60 100644
    a b class ConcreteModel(models.Model):  
    66    pass
    77
    88
    9 class ConcreteModelSubclass(ConcreteModel):
     9class ProxyModel(ConcreteModel):
     10    class Meta:
     11        proxy = True
     12
     13
     14class ConcreteModelSubclass(ProxyModel):
    1015    pass
    1116
    1217
  • tests/proxy_model_inheritance/tests.py

    diff --git a/tests/proxy_model_inheritance/tests.py b/tests/proxy_model_inheritance/tests.py
    index b0af004..33a90cb 100644
    a b import os  
    44
    55from django.core.management import call_command
    66from django.test import TestCase, TransactionTestCase
    7 from django.test.utils import extend_sys_path
     7from django.test.utils import extend_sys_path, CaptureQueriesContext
    88from django.utils._os import upath
    99
    1010from .models import (
    1111    ConcreteModel, ConcreteModelSubclass, ConcreteModelSubclassProxy,
     12    ProxyModel,
    1213)
     14from django.db import connection
    1315
    1416
    1517class ProxyModelInheritanceTests(TransactionTestCase):
    class MultiTableInheritanceProxyTest(TestCase):  
    4345        self.assertEqual(0, ConcreteModelSubclassProxy.objects.count())
    4446        self.assertEqual(0, ConcreteModelSubclass.objects.count())
    4547        self.assertEqual(0, ConcreteModel.objects.count())
     48
     49    def test_deletion_through_intermediate_proxy(self):
     50        child = ConcreteModelSubclass.objects.create()
     51        proxy = ProxyModel.objects.get(pk=child.pk)
     52        with CaptureQueriesContext(connection) as ctx:
     53            proxy.delete()
     54        print(ctx.captured_queries)
     55        self.assertFalse(ConcreteModel.objects.exists())
     56        print(ConcreteModelSubclass.objects.all())
     57        self.assertFalse(ConcreteModelSubclass.objects.exists())
Back to Top