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
08ca2110
Unverified
Commit
08ca2110
authored
Dec 05, 2017
by
Awais Jibran
Committed by
GitHub
Dec 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16782 from edx/aj/fix-unicode-error
Handle Unicode chars with AlreadyRunningError exception
parents
571be1f5
4431cec4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
lms/djangoapps/instructor/tests/test_api.py
+16
-6
lms/djangoapps/instructor/views/api.py
+1
-1
No files found.
lms/djangoapps/instructor/tests/test_api.py
View file @
08ca2110
...
@@ -252,6 +252,14 @@ def view_alreadyrunningerror(request): # pylint: disable=unused-argument
...
@@ -252,6 +252,14 @@ def view_alreadyrunningerror(request): # pylint: disable=unused-argument
@common_exceptions_400
@common_exceptions_400
def
view_alreadyrunningerror_unicode
(
request
):
# pylint: disable=unused-argument
"""
A dummy view that raises an AlreadyRunningError exception with unicode message
"""
raise
AlreadyRunningError
(
u'Text with unicode chárácters'
)
@common_exceptions_400
def
view_queue_connection_error
(
request
):
# pylint: disable=unused-argument
def
view_queue_connection_error
(
request
):
# pylint: disable=unused-argument
"""
"""
A dummy view that raises a QueueConnectionError exception.
A dummy view that raises a QueueConnectionError exception.
...
@@ -287,17 +295,19 @@ class TestCommonExceptions400(TestCase):
...
@@ -287,17 +295,19 @@ class TestCommonExceptions400(TestCase):
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertIn
(
"User does not exist"
,
resp
.
content
)
self
.
assertIn
(
"User does not exist"
,
resp
.
content
)
def
test_alreadyrunningerror
(
self
):
@ddt.data
(
True
,
False
)
self
.
request
.
is_ajax
.
return_value
=
False
def
test_alreadyrunningerror
(
self
,
is_ajax
):
self
.
request
.
is_ajax
.
return_value
=
is_ajax
resp
=
view_alreadyrunningerror
(
self
.
request
)
# pylint: disable=assignment-from-no-return
resp
=
view_alreadyrunningerror
(
self
.
request
)
# pylint: disable=assignment-from-no-return
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertIn
(
"Requested task is already running"
,
resp
.
content
)
self
.
assertIn
(
"Requested task is already running"
,
resp
.
content
)
def
test_alreadyrunningerror_ajax
(
self
):
@ddt.data
(
True
,
False
)
self
.
request
.
is_ajax
.
return_value
=
True
def
test_alreadyrunningerror_with_unicode
(
self
,
is_ajax
):
resp
=
view_alreadyrunningerror
(
self
.
request
)
# pylint: disable=assignment-from-no-return
self
.
request
.
is_ajax
.
return_value
=
is_ajax
resp
=
view_alreadyrunningerror_unicode
(
self
.
request
)
# pylint: disable=assignment-from-no-return
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertIn
(
"Requested task is already running"
,
resp
.
content
)
self
.
assertIn
(
'Text with unicode chárácters'
,
resp
.
content
)
@ddt.data
(
True
,
False
)
@ddt.data
(
True
,
False
)
def
test_queue_connection_error
(
self
,
is_ajax
):
def
test_queue_connection_error
(
self
,
is_ajax
):
...
...
lms/djangoapps/instructor/views/api.py
View file @
08ca2110
...
@@ -150,7 +150,7 @@ def common_exceptions_400(func):
...
@@ -150,7 +150,7 @@ def common_exceptions_400(func):
except
User
.
DoesNotExist
:
except
User
.
DoesNotExist
:
message
=
_
(
'User does not exist.'
)
message
=
_
(
'User does not exist.'
)
except
(
AlreadyRunningError
,
QueueConnectionError
)
as
err
:
except
(
AlreadyRunningError
,
QueueConnectionError
)
as
err
:
message
=
str
(
err
)
message
=
unicode
(
err
)
if
use_json
:
if
use_json
:
return
JsonResponseBadRequest
(
message
)
return
JsonResponseBadRequest
(
message
)
...
...
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