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
1d6d2f2a
Commit
1d6d2f2a
authored
Dec 10, 2014
by
zubair-arbi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set position to default value if POST request don't have position argument
TNL-922
parent
8a685cec
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletions
+46
-1
common/lib/xmodule/xmodule/seq_module.py
+7
-1
lms/djangoapps/courseware/tests/test_module_render.py
+39
-0
No files found.
common/lib/xmodule/xmodule/seq_module.py
View file @
1d6d2f2a
...
...
@@ -88,7 +88,13 @@ class SequenceModule(SequenceFields, XModule):
def
handle_ajax
(
self
,
dispatch
,
data
):
# TODO: bounds checking
''' get = request.POST instance '''
if
dispatch
==
'goto_position'
:
self
.
position
=
int
(
data
[
'position'
])
# set position to default value if either 'position' argument not
# found in request or it is a non-positive integer
position
=
data
.
get
(
'position'
,
u'1'
)
if
position
.
isdigit
()
and
int
(
position
)
>
0
:
self
.
position
=
int
(
position
)
else
:
self
.
position
=
1
return
json
.
dumps
({
'success'
:
True
})
raise
NotFoundError
(
'Unexpected dispatch type'
)
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
1d6d2f2a
# -*- coding: utf-8 -*-
"""
Test for lms courseware app, module render unit
"""
...
...
@@ -177,6 +178,44 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
assertEquals
(
403
,
response
.
status_code
)
self
.
assertEquals
(
'Unauthenticated'
,
response
.
content
)
def
test_missing_position_handler
(
self
):
"""
Test that sending POST request without or invalid position argument don't raise server error
"""
self
.
client
.
login
(
username
=
self
.
mock_user
.
username
,
password
=
"test"
)
dispatch_url
=
reverse
(
'xblock_handler'
,
args
=
[
self
.
course_key
.
to_deprecated_string
(),
quote_slashes
(
self
.
course_key
.
make_usage_key
(
'videosequence'
,
'Toy_Videos'
)
.
to_deprecated_string
()),
'xmodule_handler'
,
'goto_position'
]
)
response
=
self
.
client
.
post
(
dispatch_url
)
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'success'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'position'
:
''
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'success'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'position'
:
'-1'
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'success'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'position'
:
"string"
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'success'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'position'
:
u"Φυσικά"
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'success'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'position'
:
None
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'success'
:
True
})
@ddt.data
(
'pure'
,
'vertical'
)
@XBlock.register_temp_plugin
(
PureXBlock
,
identifier
=
'pure'
)
def
test_rebinding_same_user
(
self
,
block_type
):
...
...
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