1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #15903 -- Allowed not-installed models to still be referenced in related fields. Missed case from r16053.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16106 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Carl Meyer
2011-04-27 15:46:43 +00:00
parent 2f9c52dc90
commit c85b765288
4 changed files with 36 additions and 7 deletions

View File

@@ -85,8 +85,8 @@ class EggLoadingTest(TestCase):
class GetModelsTest(TestCase):
def setUp(self):
import not_installed.models
self.not_installed_module = not_installed.models
from .not_installed import models
self.not_installed_module = models
def test_get_model_only_returns_installed_models(self):
@@ -94,6 +94,13 @@ class GetModelsTest(TestCase):
get_model("not_installed", "NotInstalledModel"), None)
def test_get_model_with_not_installed(self):
self.assertEqual(
get_model(
"not_installed", "NotInstalledModel", only_installed=False),
self.not_installed_module.NotInstalledModel)
def test_get_models_only_returns_installed_models(self):
self.assertFalse(
"NotInstalledModel" in
@@ -102,3 +109,17 @@ class GetModelsTest(TestCase):
def test_get_models_with_app_label_only_returns_installed_models(self):
self.assertEqual(get_models(self.not_installed_module), [])
def test_get_models_with_not_installed(self):
self.assertTrue(
"NotInstalledModel" in [
m.__name__ for m in get_models(only_installed=False)])
class NotInstalledModelsTest(TestCase):
def test_related_not_installed_model(self):
from .not_installed.models import NotInstalledModel
self.assertEqual(
set(NotInstalledModel._meta.get_all_field_names()),
set(["id", "relatedmodel"]))