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
06dbb68e
Commit
06dbb68e
authored
Jun 13, 2014
by
Mat Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
courseware/views.py index function position value integer error correction and test
LMS-2844
parent
68087903
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
lms/djangoapps/courseware/tests/test_views.py
+17
-6
lms/djangoapps/courseware/views.py
+7
-0
No files found.
lms/djangoapps/courseware/tests/test_views.py
View file @
06dbb68e
...
@@ -80,13 +80,13 @@ class ViewsTestCase(TestCase):
...
@@ -80,13 +80,13 @@ class ViewsTestCase(TestCase):
Tests for views.py methods.
Tests for views.py methods.
"""
"""
def
setUp
(
self
):
def
setUp
(
self
):
course
=
CourseFactory
()
self
.
course
=
CourseFactory
()
chapter
=
ItemFactory
(
category
=
'chapter'
,
parent_location
=
course
.
location
)
# pylint: disable=no-member
self
.
chapter
=
ItemFactory
(
category
=
'chapter'
,
parent_location
=
self
.
course
.
location
)
# pylint: disable=no-member
se
ction
=
ItemFactory
(
category
=
'sequential'
,
parent_location
=
chapter
.
location
,
due
=
datetime
(
2013
,
9
,
18
,
11
,
30
,
00
))
se
lf
.
section
=
ItemFactory
(
category
=
'sequential'
,
parent_location
=
self
.
chapter
.
location
,
due
=
datetime
(
2013
,
9
,
18
,
11
,
30
,
00
))
vertical
=
ItemFactory
(
category
=
'vertical'
,
parent_location
=
section
.
location
)
self
.
vertical
=
ItemFactory
(
category
=
'vertical'
,
parent_location
=
self
.
section
.
location
)
self
.
component
=
ItemFactory
(
category
=
'problem'
,
parent_location
=
vertical
.
location
)
self
.
component
=
ItemFactory
(
category
=
'problem'
,
parent_location
=
self
.
vertical
.
location
)
self
.
course_key
=
course
.
id
self
.
course_key
=
self
.
course
.
id
self
.
user
=
User
.
objects
.
create
(
username
=
'dummy'
,
password
=
'123456'
,
self
.
user
=
User
.
objects
.
create
(
username
=
'dummy'
,
password
=
'123456'
,
email
=
'test@mit.edu'
)
email
=
'test@mit.edu'
)
self
.
date
=
datetime
(
2013
,
1
,
22
,
tzinfo
=
UTC
)
self
.
date
=
datetime
(
2013
,
1
,
22
,
tzinfo
=
UTC
)
...
@@ -147,6 +147,17 @@ class ViewsTestCase(TestCase):
...
@@ -147,6 +147,17 @@ class ViewsTestCase(TestCase):
self
.
assertRaises
(
Http404
,
views
.
redirect_to_course_position
,
self
.
assertRaises
(
Http404
,
views
.
redirect_to_course_position
,
mock_module
,
views
.
CONTENT_DEPTH
)
mock_module
,
views
.
CONTENT_DEPTH
)
def
test_index_invalid_position
(
self
):
request_url
=
'/'
.
join
([
'/courses'
,
self
.
course
.
id
.
to_deprecated_string
(),
self
.
chapter
.
location
.
name
,
self
.
section
.
location
.
name
,
'f'
])
response
=
self
.
client
.
get
(
request_url
)
self
.
assertEqual
(
response
.
status_code
,
404
)
def
test_registered_for_course
(
self
):
def
test_registered_for_course
(
self
):
self
.
assertFalse
(
views
.
registered_for_course
(
'Basketweaving'
,
None
))
self
.
assertFalse
(
views
.
registered_for_course
(
'Basketweaving'
,
None
))
mock_user
=
MagicMock
()
mock_user
=
MagicMock
()
...
...
lms/djangoapps/courseware/views.py
View file @
06dbb68e
...
@@ -354,6 +354,13 @@ def index(request, course_id, chapter=None, section=None,
...
@@ -354,6 +354,13 @@ def index(request, course_id, chapter=None, section=None,
section_field_data_cache
=
FieldDataCache
.
cache_for_descriptor_descendents
(
section_field_data_cache
=
FieldDataCache
.
cache_for_descriptor_descendents
(
course_key
,
user
,
section_descriptor
,
depth
=
None
)
course_key
,
user
,
section_descriptor
,
depth
=
None
)
# Verify that position a string is in fact an int
if
position
is
not
None
:
try
:
int
(
position
)
except
ValueError
:
raise
Http404
(
"Position {} is not an integer!"
.
format
(
position
))
section_module
=
get_module_for_descriptor
(
section_module
=
get_module_for_descriptor
(
request
.
user
,
request
.
user
,
request
,
request
,
...
...
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