diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-14 11:11:52 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-17 10:17:45 +0100 |
| commit | 69039becde74308d6218c72c1e410cd0049fd2bd (patch) | |
| tree | 4c7c669ad326fb376ecda6bf8532d3000a293518 /tests | |
| parent | 2732edc5f2305cf454d5df43c7d85a68c639493e (diff) | |
Deprecated get_app().
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/app_cache/tests.py | 4 | ||||
| -rw-r--r-- | tests/commands_sql/tests.py | 12 | ||||
| -rw-r--r-- | tests/defer_regress/tests.py | 8 | ||||
| -rw-r--r-- | tests/empty/tests.py | 5 | ||||
| -rw-r--r-- | tests/test_suite_override/tests.py | 2 |
5 files changed, 15 insertions, 16 deletions
diff --git a/tests/app_cache/tests.py b/tests/app_cache/tests.py index cc3637367b..484998232e 100644 --- a/tests/app_cache/tests.py +++ b/tests/app_cache/tests.py @@ -27,7 +27,7 @@ class AppCacheTests(TestCase): """ Makes a new model at runtime and ensures it goes into the right place. """ - old_models = app_cache.get_models(app_cache.get_app("app_cache")) + old_models = app_cache.get_models(app_cache.get_app_config("app_cache").models_module) # Construct a new model in a new app cache body = {} new_app_cache = BaseAppCache() @@ -42,6 +42,6 @@ class AppCacheTests(TestCase): # Make sure it appeared in the right place! self.assertEqual( old_models, - app_cache.get_models(app_cache.get_app("app_cache")), + app_cache.get_models(app_cache.get_app_config("app_cache").models_module), ) self.assertEqual(new_app_cache.get_model("app_cache", "SouthPonies"), temp_model) diff --git a/tests/commands_sql/tests.py b/tests/commands_sql/tests.py index 82e55d9861..1c2a7f0ffa 100644 --- a/tests/commands_sql/tests.py +++ b/tests/commands_sql/tests.py @@ -17,7 +17,7 @@ class SQLCommandsTestCase(TestCase): return len([o for o in output if o.startswith(cmd)]) def test_sql_create(self): - app = app_cache.get_app('commands_sql') + app = app_cache.get_app_config('commands_sql').models_module output = sql_create(app, no_style(), connections[DEFAULT_DB_ALIAS]) create_tables = [o for o in output if o.startswith('CREATE TABLE')] self.assertEqual(len(create_tables), 3) @@ -26,7 +26,7 @@ class SQLCommandsTestCase(TestCase): six.assertRegex(self, sql, r'^create table .commands_sql_book.*') def test_sql_delete(self): - app = app_cache.get_app('commands_sql') + app = app_cache.get_app_config('commands_sql').models_module output = sql_delete(app, no_style(), connections[DEFAULT_DB_ALIAS]) drop_tables = [o for o in output if o.startswith('DROP TABLE')] self.assertEqual(len(drop_tables), 3) @@ -35,19 +35,19 @@ class SQLCommandsTestCase(TestCase): six.assertRegex(self, sql, r'^drop table .commands_sql_comment.*') def test_sql_indexes(self): - app = app_cache.get_app('commands_sql') + app = app_cache.get_app_config('commands_sql').models_module output = sql_indexes(app, no_style(), connections[DEFAULT_DB_ALIAS]) # PostgreSQL creates one additional index for CharField self.assertIn(self.count_ddl(output, 'CREATE INDEX'), [3, 4]) def test_sql_destroy_indexes(self): - app = app_cache.get_app('commands_sql') + app = app_cache.get_app_config('commands_sql').models_module output = sql_destroy_indexes(app, no_style(), connections[DEFAULT_DB_ALIAS]) # PostgreSQL creates one additional index for CharField self.assertIn(self.count_ddl(output, 'DROP INDEX'), [3, 4]) def test_sql_all(self): - app = app_cache.get_app('commands_sql') + app = app_cache.get_app_config('commands_sql').models_module output = sql_all(app, no_style(), connections[DEFAULT_DB_ALIAS]) self.assertEqual(self.count_ddl(output, 'CREATE TABLE'), 3) @@ -69,7 +69,7 @@ class SQLCommandsRouterTestCase(TestCase): router.routers = self._old_routers def test_router_honored(self): - app = app_cache.get_app('commands_sql') + app = app_cache.get_app_config('commands_sql').models_module for sql_command in (sql_all, sql_create, sql_delete, sql_indexes, sql_destroy_indexes): output = sql_command(app, no_style(), connections[DEFAULT_DB_ALIAS]) self.assertEqual(len(output), 0, diff --git a/tests/defer_regress/tests.py b/tests/defer_regress/tests.py index 794ea6e18e..442af9f7cf 100644 --- a/tests/defer_regress/tests.py +++ b/tests/defer_regress/tests.py @@ -103,7 +103,7 @@ class DeferRegressionTest(TestCase): klasses = set( map( attrgetter("__name__"), - app_cache.get_models(app_cache.get_app("defer_regress")) + app_cache.get_models(app_cache.get_app_config("defer_regress").models_module) ) ) self.assertIn("Child", klasses) @@ -111,13 +111,13 @@ class DeferRegressionTest(TestCase): self.assertNotIn("Child_Deferred_value", klasses) self.assertNotIn("Item_Deferred_name", klasses) self.assertFalse(any( - k._deferred for k in app_cache.get_models(app_cache.get_app("defer_regress")))) + k._deferred for k in app_cache.get_models(app_cache.get_app_config("defer_regress").models_module))) klasses_with_deferred = set( map( attrgetter("__name__"), app_cache.get_models( - app_cache.get_app("defer_regress"), include_deferred=True + app_cache.get_app_config("defer_regress").models_module, include_deferred=True ), ) ) @@ -127,7 +127,7 @@ class DeferRegressionTest(TestCase): self.assertIn("Item_Deferred_name", klasses_with_deferred) self.assertTrue(any( k._deferred for k in app_cache.get_models( - app_cache.get_app("defer_regress"), include_deferred=True)) + app_cache.get_app_config("defer_regress").models_module, include_deferred=True)) ) @override_settings(SESSION_SERIALIZER='django.contrib.sessions.serializers.PickleSerializer') diff --git a/tests/empty/tests.py b/tests/empty/tests.py index 824c1f16e7..9fcd7a978e 100644 --- a/tests/empty/tests.py +++ b/tests/empty/tests.py @@ -1,5 +1,4 @@ from django.apps import app_cache -from django.core.exceptions import ImproperlyConfigured from django.test import TestCase from django.test.utils import override_settings from django.utils import six @@ -31,6 +30,6 @@ class NoModelTests(TestCase): """ @override_settings(INSTALLED_APPS=("empty.no_models",)) def test_no_models(self): - with six.assertRaisesRegex(self, ImproperlyConfigured, + with six.assertRaisesRegex(self, LookupError, "No app with label 'no_models'."): - app_cache.get_app('no_models') + app_cache.get_app_config('no_models') diff --git a/tests/test_suite_override/tests.py b/tests/test_suite_override/tests.py index ed336076e7..5c5e433dbc 100644 --- a/tests/test_suite_override/tests.py +++ b/tests/test_suite_override/tests.py @@ -20,7 +20,7 @@ class SuiteOverrideTest(IgnoreAllDeprecationWarningsMixin, unittest.TestCase): """ from django.test.simple import build_suite - app = app_cache.get_app("test_suite_override") + app = app_cache.get_app_config("test_suite_override").models_module suite = build_suite(app) self.assertEqual(suite.countTestCases(), 1) |
