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
df2f347a
Commit
df2f347a
authored
Jun 07, 2016
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12670 from cpennington/reset-urls-favicon-tests
Reset urls favicon tests
parents
194d33ea
c124fb34
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
21 deletions
+19
-21
common/djangoapps/util/testing.py
+9
-7
lms/djangoapps/courseware/tests/test_favicon.py
+10
-14
No files found.
common/djangoapps/util/testing.py
View file @
df2f347a
...
...
@@ -31,8 +31,14 @@ class UrlResetMixin(object):
URLCONF_MODULES
=
None
def
_reset_urls
(
self
,
urlconf_modules
):
def
reset_urls
(
self
,
urlconf_modules
=
None
):
"""Reset `urls.py` for a set of Django apps."""
if
urlconf_modules
is
None
:
urlconf_modules
=
[
settings
.
ROOT_URLCONF
]
if
self
.
URLCONF_MODULES
is
not
None
:
urlconf_modules
.
extend
(
self
.
URLCONF_MODULES
)
for
urlconf
in
urlconf_modules
:
if
urlconf
in
sys
.
modules
:
reload
(
sys
.
modules
[
urlconf
])
...
...
@@ -61,12 +67,8 @@ class UrlResetMixin(object):
"""
super
(
UrlResetMixin
,
self
)
.
setUp
()
urlconf_modules
=
[
settings
.
ROOT_URLCONF
]
if
self
.
URLCONF_MODULES
is
not
None
:
urlconf_modules
.
extend
(
self
.
URLCONF_MODULES
)
self
.
_reset_urls
(
urlconf_modules
)
self
.
addCleanup
(
lambda
:
self
.
_reset_urls
(
urlconf_modules
))
self
.
reset_urls
()
self
.
addCleanup
(
self
.
reset_urls
)
class
EventTestMixin
(
object
):
...
...
lms/djangoapps/courseware/tests/test_favicon.py
View file @
df2f347a
...
...
@@ -9,12 +9,14 @@ from nose.plugins.attrib import attr
import
sys
from
util.testing
import
UrlResetMixin
@attr
(
'shard_1'
)
class
FaviconTestCase
(
TestCase
):
def
setUp
(
self
):
super
(
FaviconTestCase
,
self
)
.
setUp
()
@attr
(
'shard_1'
)
class
FaviconTestCase
(
UrlResetMixin
,
TestCase
):
"""
Tests of the courseware favicon.
"""
def
test_favicon_redirect
(
self
):
resp
=
self
.
client
.
get
(
"/favicon.ico"
)
...
...
@@ -27,15 +29,7 @@ class FaviconTestCase(TestCase):
@override_settings
(
FAVICON_PATH
=
"images/foo.ico"
)
def
test_favicon_redirect_with_favicon_path_setting
(
self
):
# for some reason I had to put this inline rather than just using
# the UrlResetMixin
urlconf
=
settings
.
ROOT_URLCONF
if
urlconf
in
sys
.
modules
:
reload
(
sys
.
modules
[
urlconf
])
clear_url_caches
()
resolve
(
"/"
)
self
.
reset_urls
()
resp
=
self
.
client
.
get
(
"/favicon.ico"
)
self
.
assertEqual
(
resp
.
status_code
,
301
)
...
...
@@ -46,14 +40,16 @@ class FaviconTestCase(TestCase):
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"USE_CUSTOM_THEME"
:
True
})
@override_settings
(
FAVICON_PATH
=
"images/bar_fav.ico"
)
@override_settings
(
THEME_NAME
=
"bar"
)
def
test_favicon_redirect_with_theme
(
self
):
self
.
assertEqual
(
settings
.
FEATURES
[
"USE_CUSTOM_THEME"
],
True
)
self
.
reset_urls
()
resp
=
self
.
client
.
get
(
"/favicon.ico"
)
self
.
assertEqual
(
resp
.
status_code
,
301
)
self
.
assertRedirects
(
resp
,
"/static/images/
foo
.ico"
,
"/static/images/
bar_fav
.ico"
,
status_code
=
301
,
target_status_code
=
404
# @@@ how to avoid 404?
)
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