PageRenderTime 36ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/modeltests/proxy_model_inheritance/tests.py

https://code.google.com/p/mango-py/
Python | 36 lines | 23 code | 6 blank | 7 comment | 0 complexity | 8f99aa76615311fe0f69bb421475e7f6 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. """
  2. XX. Proxy model inheritance
  3. Proxy model inheritance across apps can result in syncdb not creating the table
  4. for the proxied model (as described in #12286). This test creates two dummy
  5. apps and calls syncdb, then verifies that the table has been created.
  6. """
  7. import os
  8. import sys
  9. from django.conf import settings, Settings
  10. from django.core.management import call_command
  11. from django.db.models.loading import load_app
  12. from django.test import TransactionTestCase
  13. class ProxyModelInheritanceTests(TransactionTestCase):
  14. def setUp(self):
  15. self.old_sys_path = sys.path[:]
  16. sys.path.append(os.path.dirname(os.path.abspath(__file__)))
  17. self.old_installed_apps = settings.INSTALLED_APPS
  18. settings.INSTALLED_APPS = ('app1', 'app2')
  19. map(load_app, settings.INSTALLED_APPS)
  20. call_command('syncdb', verbosity=0)
  21. global ProxyModel, NiceModel
  22. from app1.models import ProxyModel
  23. from app2.models import NiceModel
  24. def tearDown(self):
  25. settings.INSTALLED_APPS = self.old_installed_apps
  26. sys.path = self.old_sys_path
  27. def test_table_exists(self):
  28. self.assertEqual(NiceModel.objects.all().count(), 0)
  29. self.assertEqual(ProxyModel.objects.all().count(), 0)