Commit 029f4a5e by Calen Pennington

Use a contextmanager to cleanup after manipulating the current request in email rendering tests

parent 71bb7f0b
...@@ -18,7 +18,6 @@ from mock import Mock, patch ...@@ -18,7 +18,6 @@ from mock import Mock, patch
from django.http import HttpResponse from django.http import HttpResponse
from django.conf import settings from django.conf import settings
from edxmako.shortcuts import render_to_string from edxmako.shortcuts import render_to_string
from edxmako.tests import mako_middleware_process_request
from util.request import safe_get_host from util.request import safe_get_host
from util.testing import EventTestMixin from util.testing import EventTestMixin
from openedx.core.djangoapps.theming.test_util import with_is_edx_domain from openedx.core.djangoapps.theming.test_util import with_is_edx_domain
...@@ -173,7 +172,7 @@ class ReactivationEmailTests(EmailTestMixin, TestCase): ...@@ -173,7 +172,7 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
request.META['HTTP_HOST'] = "aGenericValidHostName" request.META['HTTP_HOST'] = "aGenericValidHostName"
self.append_allowed_hosts("aGenericValidHostName") self.append_allowed_hosts("aGenericValidHostName")
mako_middleware_process_request(request) with patch('edxmako.request_context.get_current_request', return_value=request):
body = render_to_string('emails/activation_email.txt', context) body = render_to_string('emails/activation_email.txt', context)
host = safe_get_host(request) host = safe_get_host(request)
...@@ -368,7 +367,7 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase): ...@@ -368,7 +367,7 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase):
request.META['HTTP_HOST'] = "aGenericValidHostName" request.META['HTTP_HOST'] = "aGenericValidHostName"
self.append_allowed_hosts("aGenericValidHostName") self.append_allowed_hosts("aGenericValidHostName")
mako_middleware_process_request(request) with patch('edxmako.request_context.get_current_request', return_value=request):
body = render_to_string('emails/confirm_email_change.txt', context) body = render_to_string('emails/confirm_email_change.txt', context)
url = safe_get_host(request) url = safe_get_host(request)
......
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