diff options
| author | wrwrwr <git@wr.waw.pl> | 2014-11-29 18:09:40 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-12-01 11:34:15 -0500 |
| commit | 9136ceb6fb8225625631671147ff70c1fcfbbcdc (patch) | |
| tree | fe846d89151c87b7474fbe2ef8cdedcde578dba4 /tests/cache | |
| parent | e6f19ec3223ba7c398aea515c5e0f8b93e6f4359 (diff) | |
Replaced router.routers usage with override_settings(DATABASE_ROUTERS); refs #23933.
Diffstat (limited to 'tests/cache')
| -rw-r--r-- | tests/cache/tests.py | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 9dfd7af15d..e3ad724a86 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -19,7 +19,7 @@ from django.core import management from django.core.cache import (cache, caches, CacheKeyWarning, InvalidCacheBackendError, DEFAULT_CACHE_ALIAS) from django.core.context_processors import csrf -from django.db import connection, connections, router, transaction +from django.db import connection, connections, transaction from django.core.cache.utils import make_template_fragment_key from django.http import HttpResponse, StreamingHttpResponse from django.middleware.cache import (FetchFromCacheMiddleware, @@ -974,29 +974,25 @@ class DBCacheRouter(object): class CreateCacheTableForDBCacheTests(TestCase): multi_db = True + @override_settings(DATABASE_ROUTERS=[DBCacheRouter()]) def test_createcachetable_observes_database_router(self): - old_routers = router.routers - try: - router.routers = [DBCacheRouter()] - # cache table should not be created on 'default' - with self.assertNumQueries(0, using='default'): - management.call_command('createcachetable', - database='default', - verbosity=0, interactive=False) - # cache table should be created on 'other' - # Queries: - # 1: check table doesn't already exist - # 2: create savepoint (if transactional DDL is supported) - # 3: create the table - # 4: create the index - # 5: release savepoint (if transactional DDL is supported) - num = 5 if connections['other'].features.can_rollback_ddl else 3 - with self.assertNumQueries(num, using='other'): - management.call_command('createcachetable', - database='other', - verbosity=0, interactive=False) - finally: - router.routers = old_routers + # cache table should not be created on 'default' + with self.assertNumQueries(0, using='default'): + management.call_command('createcachetable', + database='default', + verbosity=0, interactive=False) + # cache table should be created on 'other' + # Queries: + # 1: check table doesn't already exist + # 2: create savepoint (if transactional DDL is supported) + # 3: create the table + # 4: create the index + # 5: release savepoint (if transactional DDL is supported) + num = 5 if connections['other'].features.can_rollback_ddl else 3 + with self.assertNumQueries(num, using='other'): + management.call_command('createcachetable', + database='other', + verbosity=0, interactive=False) class PicklingSideEffect(object): |
