Ticket #18083: ticket-18083-failling-testcase.diff

File ticket-18083-failling-testcase.diff, 2.8 KB (added by Simon Charette, 13 years ago)

Failing testcase incorporated into django's test suite

  • tests/modeltests/proxy_model_inheritance/models.py

    diff --git a/tests/modeltests/proxy_model_inheritance/models.py b/tests/modeltests/proxy_model_inheritance/models.py
    index e69de29..ef9ac6b 100644
    a b  
     1
     2from django.db import models
     3
     4
     5class ConcreteModel(models.Model):
     6    pass
     7
     8class ConcreteModelSubclass(ConcreteModel):
     9    pass
     10
     11class ConcreteModelSubclassProxy(ConcreteModelSubclass):
     12    class Meta:
     13        proxy = True
  • tests/modeltests/proxy_model_inheritance/tests.py

    diff --git a/tests/modeltests/proxy_model_inheritance/tests.py b/tests/modeltests/proxy_model_inheritance/tests.py
    index ae5ab20..94805d9 100644
    a b  
    1 """
    2 XX. Proxy model inheritance
    3 
    4 Proxy model inheritance across apps can result in syncdb not creating the table
    5 for the proxied model (as described in #12286).  This test creates two dummy
    6 apps and calls syncdb, then verifies that the table has been created.
    7 """
    8 
    91from __future__ import absolute_import
    102
    113import os
     
    146from django.conf import settings
    157from django.core.management import call_command
    168from django.db.models.loading import cache, load_app
    17 from django.test import TransactionTestCase
     9from django.test import TestCase, TransactionTestCase
    1810from django.test.utils import override_settings
    1911
     12from .models import (ConcreteModel, ConcreteModelSubclass,
     13    ConcreteModelSubclassProxy)
     14
    2015
    2116@override_settings(INSTALLED_APPS=('app1', 'app2'))
    2217class ProxyModelInheritanceTests(TransactionTestCase):
     18    """
     19    Proxy model inheritance across apps can result in syncdb not creating the table
     20    for the proxied model (as described in #12286).  This test creates two dummy
     21    apps and calls syncdb, then verifies that the table has been created.
     22    """
    2323
    2424    def setUp(self):
    2525        self.old_sys_path = sys.path[:]
    def test_table_exists(self):  
    4141        from .app2.models import NiceModel
    4242        self.assertEqual(NiceModel.objects.all().count(), 0)
    4343        self.assertEqual(ProxyModel.objects.all().count(), 0)
     44
     45class MultiTableInheritanceProxyTest(TestCase):
     46
     47    def test_model_subclass_proxy(self):
     48        """
     49        Deleting an instance of a model proxing a multi-table inherited subclass
     50        might not cascade delete down the whole inheritance chain while doing it
     51        on the proxied concrete class works (as described in #18083).
     52        """
     53        instance = ConcreteModelSubclassProxy.objects.create()
     54        instance.delete()
     55        self.assertEqual(0, ConcreteModelSubclassProxy.objects.count())
     56        self.assertEqual(0, ConcreteModelSubclass.objects.count())
     57        self.assertEqual(0, ConcreteModel.objects.count())
Back to Top