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
a77923dc
Commit
a77923dc
authored
Jun 19, 2015
by
Greg Price
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8564 from edx/gprice/discussion-api-whitespace-content
Handle whitespace-only content in discussion API
parents
6cd8889f
174b4d94
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
lms/djangoapps/discussion_api/tests/test_serializers.py
+16
-4
openedx/core/lib/api/fields.py
+1
-1
No files found.
lms/djangoapps/discussion_api/tests/test_serializers.py
View file @
a77923dc
...
...
@@ -473,6 +473,16 @@ class ThreadSerializerDeserializationTest(CommentsServiceMockMixin, UrlResetMixi
{
field
:
[
"This field is required."
]}
)
@ddt.data
(
""
,
" "
)
def
test_create_empty_string
(
self
,
value
):
data
=
self
.
minimal_data
.
copy
()
data
.
update
({
field
:
value
for
field
in
[
"topic_id"
,
"title"
,
"raw_body"
]})
serializer
=
ThreadSerializer
(
data
=
data
,
context
=
get_context
(
self
.
course
,
self
.
request
))
self
.
assertEqual
(
serializer
.
errors
,
{
field
:
[
"This field is required."
]
for
field
in
[
"topic_id"
,
"title"
,
"raw_body"
]}
)
def
test_create_type
(
self
):
self
.
register_post_thread_response
({
"id"
:
"test_id"
})
data
=
self
.
minimal_data
.
copy
()
...
...
@@ -529,10 +539,11 @@ class ThreadSerializerDeserializationTest(CommentsServiceMockMixin, UrlResetMixi
for
key
in
data
:
self
.
assertEqual
(
saved
[
key
],
data
[
key
])
def
test_update_empty_string
(
self
):
@ddt.data
(
""
,
" "
)
def
test_update_empty_string
(
self
,
value
):
serializer
=
ThreadSerializer
(
self
.
existing_thread
,
data
=
{
field
:
""
for
field
in
[
"topic_id"
,
"title"
,
"raw_body"
]},
data
=
{
field
:
value
for
field
in
[
"topic_id"
,
"title"
,
"raw_body"
]},
partial
=
True
,
context
=
get_context
(
self
.
course
,
self
.
request
)
)
...
...
@@ -735,10 +746,11 @@ class CommentSerializerDeserializationTest(CommentsServiceMockMixin, ModuleStore
self
.
assertEqual
(
saved
[
"endorsed_by"
],
self
.
user
.
username
)
self
.
assertEqual
(
saved
[
"endorsed_at"
],
"2015-06-05T00:00:00Z"
)
def
test_update_empty_raw_body
(
self
):
@ddt.data
(
""
,
" "
)
def
test_update_empty_raw_body
(
self
,
value
):
serializer
=
CommentSerializer
(
self
.
existing_comment
,
data
=
{
"raw_body"
:
""
},
data
=
{
"raw_body"
:
value
},
partial
=
True
,
context
=
get_context
(
self
.
course
,
self
.
request
)
)
...
...
openedx/core/lib/api/fields.py
View file @
a77923dc
...
...
@@ -33,5 +33,5 @@ class NonEmptyCharField(CharField):
"""
def
validate
(
self
,
value
):
super
(
NonEmptyCharField
,
self
)
.
validate
(
value
)
if
not
value
:
if
not
value
.
strip
()
:
raise
ValidationError
(
self
.
error_messages
[
"required"
])
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