Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
029f4a5e
Commit
029f4a5e
authored
May 26, 2016
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a contextmanager to cleanup after manipulating the current request in email rendering tests
parent
71bb7f0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
common/djangoapps/student/tests/test_email.py
+6
-7
No files found.
common/djangoapps/student/tests/test_email.py
View file @
029f4a5e
...
...
@@ -18,7 +18,6 @@ from mock import Mock, patch
from
django.http
import
HttpResponse
from
django.conf
import
settings
from
edxmako.shortcuts
import
render_to_string
from
edxmako.tests
import
mako_middleware_process_request
from
util.request
import
safe_get_host
from
util.testing
import
EventTestMixin
from
openedx.core.djangoapps.theming.test_util
import
with_is_edx_domain
...
...
@@ -173,9 +172,9 @@ class ReactivationEmailTests(EmailTestMixin, TestCase):
request
.
META
[
'HTTP_HOST'
]
=
"aGenericValidHostName"
self
.
append_allowed_hosts
(
"aGenericValidHostName"
)
mako_middleware_process_request
(
request
)
body
=
render_to_string
(
'emails/activation_email.txt'
,
context
)
host
=
safe_get_host
(
request
)
with
patch
(
'edxmako.request_context.get_current_request'
,
return_value
=
request
):
body
=
render_to_string
(
'emails/activation_email.txt'
,
context
)
host
=
safe_get_host
(
request
)
self
.
assertIn
(
host
,
body
)
...
...
@@ -368,9 +367,9 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase):
request
.
META
[
'HTTP_HOST'
]
=
"aGenericValidHostName"
self
.
append_allowed_hosts
(
"aGenericValidHostName"
)
mako_middleware_process_request
(
request
)
body
=
render_to_string
(
'emails/confirm_email_change.txt'
,
context
)
url
=
safe_get_host
(
request
)
with
patch
(
'edxmako.request_context.get_current_request'
,
return_value
=
request
):
body
=
render_to_string
(
'emails/confirm_email_change.txt'
,
context
)
url
=
safe_get_host
(
request
)
self
.
assertIn
(
url
,
body
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment