summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-12-26 19:20:38 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-12-26 19:25:09 +0100
commite179291fa58b08c6e52cceb1590666fbcca8f363 (patch)
treebe523e2e95eb23b9c68103b1389a923f37027190
parentb355e98a5091a76ad4b8657a6a971e7e0595aa26 (diff)
Added tests for invalid values of INSTALLED_APPS.
-rw-r--r--tests/apps/tests.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/apps/tests.py b/tests/apps/tests.py
index a597bc955b..53afd8e8e9 100644
--- a/tests/apps/tests.py
+++ b/tests/apps/tests.py
@@ -3,6 +3,7 @@ from __future__ import absolute_import, unicode_literals
from django.apps import apps
from django.apps.registry import Apps
from django.conf import settings
+from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.test import TestCase, override_settings
@@ -28,6 +29,7 @@ SOME_INSTALLED_APPS_NAMES = [
SOME_INSTALLED_APPS_WTH_MODELS_NAMES = SOME_INSTALLED_APPS_NAMES[:4]
+
class AppsTests(TestCase):
def test_singleton_master(self):
@@ -53,6 +55,38 @@ class AppsTests(TestCase):
# ready regardless of whether populate_models() has run.
self.assertTrue(apps.ready)
+ def test_bad_app_config(self):
+ """
+ Tests when INSTALLED_APPS contains an incorrect app config.
+ """
+ with self.assertRaises(ImproperlyConfigured):
+ with self.settings(INSTALLED_APPS=['apps.apps.BadConfig']):
+ pass
+
+ def test_not_an_app_config(self):
+ """
+ Tests when INSTALLED_APPS contains a class that isn't an app config.
+ """
+ with self.assertRaises(ImproperlyConfigured):
+ with self.settings(INSTALLED_APPS=['apps.apps.NotAConfig']):
+ pass
+
+ def test_no_such_app(self):
+ """
+ Tests when INSTALLED_APPS contains an app config for an app that doesn't exist.
+ """
+ with self.assertRaises(ImportError):
+ with self.settings(INSTALLED_APPS=['apps.apps.NoSuchApp']):
+ pass
+
+ def test_no_such_app_config(self):
+ """
+ Tests when INSTALLED_APPS contains an entry that doesn't exist.
+ """
+ with self.assertRaises(ImportError):
+ with self.settings(INSTALLED_APPS=['apps.apps.NoSuchConfig']):
+ pass
+
@override_settings(INSTALLED_APPS=SOME_INSTALLED_APPS)
def test_get_app_configs(self):
"""