Skip to content

Commit

Permalink
Moving session backend selection to manage.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Jan 14, 2016
1 parent cf3d16c commit ce5ece1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cms/tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def test_cache_placeholder(self):
'django.middleware.cache.FetchFromCacheMiddleware'
]
middleware = [mw for mw in settings.MIDDLEWARE_CLASSES if mw not in exclude]
with self.settings(CMS_PAGE_CACHE=False, MIDDLEWARE_CLASSES=middleware, SESSION_ENGINE="django.contrib.sessions.backends.cache",):
with self.settings(CMS_PAGE_CACHE=False, MIDDLEWARE_CLASSES=middleware):
with self.assertNumQueries(FuzzyInt(13, 17)):
self.client.get('/en/')
with self.assertNumQueries(FuzzyInt(5, 9)):
self.client.get('/en/')
with self.settings(CMS_PAGE_CACHE=False, MIDDLEWARE_CLASSES=middleware, CMS_PLACEHOLDER_CACHE=False, SESSION_ENGINE="django.contrib.sessions.backends.cache",):
with self.settings(CMS_PAGE_CACHE=False, MIDDLEWARE_CLASSES=middleware, CMS_PLACEHOLDER_CACHE=False):
with self.assertNumQueries(FuzzyInt(7, 11)):
self.client.get('/en/')

Expand Down Expand Up @@ -135,7 +135,7 @@ def test_cache_page(self):
]
mw_classes = [mw for mw in settings.MIDDLEWARE_CLASSES if mw not in exclude]

with self.settings(MIDDLEWARE_CLASSES=mw_classes, SESSION_ENGINE="django.contrib.sessions.backends.cache",):
with self.settings(MIDDLEWARE_CLASSES=mw_classes):

# Silly to do these tests if this setting isn't True
page_cache_setting = get_cms_setting('PAGE_CACHE')
Expand Down Expand Up @@ -212,7 +212,7 @@ def test_invalidate_restart(self):
]
mw_classes = [mw for mw in settings.MIDDLEWARE_CLASSES if mw not in exclude]

with self.settings(MIDDLEWARE_CLASSES=mw_classes, SESSION_ENGINE="django.contrib.sessions.backends.cache",):
with self.settings(MIDDLEWARE_CLASSES=mw_classes):

# Silly to do these tests if this setting isn't True
page_cache_setting = get_cms_setting('PAGE_CACHE')
Expand Down
6 changes: 5 additions & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ def __getitem__(self, item):
return 'notmigrations'

dynamic_configs['MIGRATION_MODULES'] = DisableMigrations()
if 'test' in sys.argv:
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
else:
SESSION_ENGINE = "django.contrib.sessions.backends.db"

app_manage.main(
['cms', 'menus'],
Expand All @@ -183,7 +187,7 @@ def __getitem__(self, item):
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
},
SESSION_ENGINE="django.contrib.sessions.backends.db",
SESSION_ENGINE=SESSION_ENGINE,
CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True,
DEBUG=True,
DATABASE_SUPPORTS_TRANSACTIONS=True,
Expand Down

0 comments on commit ce5ece1

Please sign in to comment.