Commit c98a7756 by Jay Zoldak

Make the UrlResetMixin load the urlconf after resetting it, and fix the comment…

Make the UrlResetMixin load the urlconf after resetting it, and fix the comment client test that was leaving ENABLE_DISCUSSION_SERVICE at True
parent 2b6d338d
import sys import sys
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import clear_url_caches from django.core.urlresolvers import clear_url_caches, resolve
class UrlResetMixin(object): class UrlResetMixin(object):
...@@ -27,6 +27,9 @@ class UrlResetMixin(object): ...@@ -27,6 +27,9 @@ class UrlResetMixin(object):
reload(sys.modules[urlconf]) reload(sys.modules[urlconf])
clear_url_caches() clear_url_caches()
# Resolve a URL so that the new urlconf gets loaded
resolve('/')
def setUp(self): def setUp(self):
"""Reset django default urlconf before tests and after tests""" """Reset django default urlconf before tests and after tests"""
super(UrlResetMixin, self).setUp() super(UrlResetMixin, self).setUp()
......
import logging import logging
from django.conf import settings
from django.test.utils import override_settings from django.test.utils import override_settings
from django.test.client import Client from django.test.client import Client
from django.contrib.auth.models import User from django.contrib.auth.models import User
...@@ -21,16 +20,13 @@ log = logging.getLogger(__name__) ...@@ -21,16 +20,13 @@ log = logging.getLogger(__name__)
@override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) @override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE)
@patch('comment_client.utils.requests.request') @patch('comment_client.utils.requests.request')
class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase): class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
@patch.dict("django.conf.settings.MITX_FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
def setUp(self): def setUp(self):
# This feature affects the contents of urls.py, so we change # Patching the ENABLE_DISCUSSION_SERVICE value affects the contents of urls.py,
# it before the call to super.setUp() which reloads urls.py (because # so we need to call super.setUp() which reloads urls.py (because
# of the UrlResetMixin) # of the UrlResetMixin)
# This setting is cleaned up at the end of the test by @override_settings, which
# restores all of the old settings
settings.MITX_FEATURES['ENABLE_DISCUSSION_SERVICE'] = True
super(ViewsTestCase, self).setUp() super(ViewsTestCase, self).setUp()
# create a course # create a course
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment