Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
c830537e
Commit
c830537e
authored
10 years ago
by
Adam
Browse files
Options
Downloads
Plain Diff
Merge pull request #4844 from edx/release
Release
parents
5c64c5b2
09d86c22
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/djangoapps/edxmako/shortcuts.py
+1
-1
1 addition, 1 deletion
common/djangoapps/edxmako/shortcuts.py
common/djangoapps/edxmako/template.py
+1
-1
1 addition, 1 deletion
common/djangoapps/edxmako/template.py
common/djangoapps/edxmako/tests.py
+24
-1
24 additions, 1 deletion
common/djangoapps/edxmako/tests.py
with
26 additions
and
3 deletions
common/djangoapps/edxmako/shortcuts.py
+
1
−
1
View file @
c830537e
...
...
@@ -92,7 +92,7 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'):
context_instance
[
'
marketing_link
'
]
=
marketing_link
# In various testing contexts, there might not be a current request context.
if
edxmako
.
middleware
.
REQUEST_CONTEXT
.
context
is
not
None
:
if
getattr
(
edxmako
.
middleware
.
REQUEST_CONTEXT
,
"
context
"
,
None
)
:
for
d
in
edxmako
.
middleware
.
REQUEST_CONTEXT
.
context
:
context_dictionary
.
update
(
d
)
for
d
in
context_instance
:
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/edxmako/template.py
+
1
−
1
View file @
c830537e
...
...
@@ -48,7 +48,7 @@ class Template(MakoTemplate):
context_dictionary
=
{}
# In various testing contexts, there might not be a current request context.
if
edxmako
.
middleware
.
REQUEST_CONTEXT
.
context
is
not
None
:
if
getattr
(
edxmako
.
middleware
.
REQUEST_CONTEXT
,
"
context
"
,
None
)
:
for
d
in
edxmako
.
middleware
.
REQUEST_CONTEXT
.
context
:
context_dictionary
.
update
(
d
)
for
d
in
context_instance
:
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/edxmako/tests.py
+
24
−
1
View file @
c830537e
from
mock
import
patch
,
Mock
import
unittest
from
django.conf
import
settings
from
django.http
import
HttpResponse
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
...
...
@@ -7,7 +10,7 @@ from django.test.client import RequestFactory
from
django.core.urlresolvers
import
reverse
import
edxmako.middleware
from
edxmako
import
add_lookup
,
LOOKUP
from
edxmako.shortcuts
import
marketing_link
from
edxmako.shortcuts
import
marketing_link
,
render_to_string
from
student.tests.factories
import
UserFactory
from
util.testing
import
UrlResetMixin
...
...
@@ -71,6 +74,26 @@ class MakoMiddlewareTest(TestCase):
# requestcontext should be None.
self
.
assertIsNone
(
edxmako
.
middleware
.
REQUEST_CONTEXT
.
context
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'
lms.urls
'
,
'
Test only valid in lms
'
)
@patch
(
"
edxmako.middleware.REQUEST_CONTEXT
"
)
def
test_render_to_string_when_no_global_context_lms
(
self
,
context_mock
):
"""
Test render_to_string() when makomiddleware has not initialized
the threadlocal REQUEST_CONTEXT.context. This is meant to run in LMS.
"""
del
context_mock
.
context
self
.
assertIn
(
"
this module is temporarily unavailable
"
,
render_to_string
(
"
courseware/error-message.html
"
,
None
))
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'
cms.urls
'
,
'
Test only valid in cms
'
)
@patch
(
"
edxmako.middleware.REQUEST_CONTEXT
"
)
def
test_render_to_string_when_no_global_context_cms
(
self
,
context_mock
):
"""
Test render_to_string() when makomiddleware has not initialized
the threadlocal REQUEST_CONTEXT.context. This is meant to run in CMS.
"""
del
context_mock
.
context
self
.
assertIn
(
"
We
'
re having trouble rendering your component
"
,
render_to_string
(
"
html_error.html
"
,
None
))
def
mako_middleware_process_request
(
request
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment