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
9599c31a
Commit
9599c31a
authored
Aug 04, 2014
by
Usman Khalid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch InvalidKeyError in static_tab view.
LMS-11189
parent
46b1c850
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
lms/djangoapps/courseware/tests/helpers.py
+2
-0
lms/djangoapps/courseware/tests/test_tabs.py
+7
-1
lms/djangoapps/courseware/views.py
+5
-1
No files found.
lms/djangoapps/courseware/tests/helpers.py
View file @
9599c31a
...
...
@@ -49,9 +49,11 @@ def get_request_for_user(user):
request
=
RequestFactory
()
request
.
user
=
user
request
.
COOKIES
=
{}
request
.
META
=
{}
request
.
is_secure
=
lambda
:
True
request
.
get_host
=
lambda
:
"edx.org"
request
.
method
=
'GET'
return
request
...
...
lms/djangoapps/courseware/tests/test_tabs.py
View file @
9599c31a
...
...
@@ -4,8 +4,9 @@ Test cases for tabs.
from
mock
import
MagicMock
,
Mock
,
patch
from
courseware.courses
import
get_course_by_id
from
courseware.views
import
get_static_tab_contents
from
courseware.views
import
get_static_tab_contents
,
static_tab
from
django.http
import
Http404
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
...
...
@@ -43,6 +44,11 @@ class StaticTabDateTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
"OOGIE BLOOGIE"
,
resp
.
content
)
def
test_invalid_course_key
(
self
):
request
=
get_request_for_user
(
UserFactory
.
create
())
with
self
.
assertRaises
(
Http404
):
static_tab
(
request
,
'edX/toy'
,
'new_tab'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
def
test_get_static_tab_contents
(
self
):
course
=
get_course_by_id
(
self
.
toy_course_key
)
...
...
lms/djangoapps/courseware/views.py
View file @
9599c31a
...
...
@@ -549,7 +549,11 @@ def static_tab(request, course_id, tab_slug):
Assumes the course_id is in a valid format.
"""
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
try
:
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
except
InvalidKeyError
:
raise
Http404
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
)
tab
=
CourseTabList
.
get_tab_by_slug
(
course
.
tabs
,
tab_slug
)
...
...
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