Ticket #13323: same_app_label_test.diff

File same_app_label_test.diff, 3.3 KB (added by chtito, 15 years ago)
  • new file tests/regressiontests/same_app_label/package1/app/models.py

    diff --git a/tests/regressiontests/same_app_label/__init__.py b/tests/regressiontests/same_app_label/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/same_app_label/models.py b/tests/regressiontests/same_app_label/models.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/same_app_label/package1/__init__.py b/tests/regressiontests/same_app_label/package1/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/same_app_label/package1/app/__init__.py b/tests/regressiontests/same_app_label/package1/app/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/same_app_label/package1/app/models.py b/tests/regressiontests/same_app_label/package1/app/models.py
    new file mode 100644
    index 0000000..0e2ccb0
    - +  
     1from django.db import models
     2
     3class NiceModel1(models.Model):
     4    pass
  • new file tests/regressiontests/same_app_label/package2/app/models.py

    diff --git a/tests/regressiontests/same_app_label/package2/__init__.py b/tests/regressiontests/same_app_label/package2/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/same_app_label/package2/app/__init__.py b/tests/regressiontests/same_app_label/package2/app/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/regressiontests/same_app_label/package2/app/models.py b/tests/regressiontests/same_app_label/package2/app/models.py
    new file mode 100644
    index 0000000..4b437e0
    - +  
     1from django.db import models
     2
     3class NiceModel2(models.Model):
     4    pass
  • new file tests/regressiontests/same_app_label/tests.py

    diff --git a/tests/regressiontests/same_app_label/tests.py b/tests/regressiontests/same_app_label/tests.py
    new file mode 100644
    index 0000000..71344b7
    - +  
     1"""
     2XX. Proxy model inheritance
     3
     4Proxy model inheritance across apps can result in syncdb not creating the table
     5for the proxied model (as described in #12286).  This test creates two dummy
     6apps and calls syncdb, then verifies that the table has been created.
     7"""
     8
     9import os
     10import sys
     11
     12from django.conf import settings, Settings
     13from django.core.management import call_command
     14from django.db.models.loading import load_app
     15from django.test import TransactionTestCase
     16
     17class ProxyModelInheritanceTests(TransactionTestCase):
     18
     19    def setUp(self):
     20        self.old_sys_path = sys.path
     21        sys.path.append(os.path.dirname(os.path.abspath(__file__)))
     22        self.old_installed_apps = settings.INSTALLED_APPS
     23        settings.INSTALLED_APPS = ('package1.app', 'package2.app')
     24        map(load_app, settings.INSTALLED_APPS)
     25        call_command('syncdb', verbosity=0)
     26        from package1.app.models import NiceModel1
     27        from package2.app.models import NiceModel2
     28        self.imported_models = NiceModel1, NiceModel2
     29
     30    def tearDown(self):
     31        settings.INSTALLED_APPS = self.old_installed_apps
     32        sys.path = self.old_sys_path
     33
     34    def test_table_exists(self):
     35        # make sure we may use the ``reset`` command with full application path:
     36        call_command('reset', 'package1.app', interactive=False)
     37        for m in self.imported_models:
     38            self.assertEquals(m.objects.all().count(), 0)
Back to Top