Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-val
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-val
Commits
fcd59d72
Commit
fcd59d72
authored
Jul 10, 2017
by
Mushtaq Ali
Committed by
GitHub
Jul 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #78 from edx/mushtaq/fix-coursevideo-bug
Filters out invalid data from course_videos list
parents
a03f599e
f37679ed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
7 deletions
+34
-7
edxval/serializers.py
+11
-6
edxval/tests/constants.py
+8
-0
edxval/tests/test_views.py
+14
-0
setup.py
+1
-1
No files found.
edxval/serializers.py
View file @
fcd59d72
...
...
@@ -99,13 +99,14 @@ class CourseSerializer(serializers.RelatedField):
"""
Convert data into CourseVideo instance and image filename tuple.
"""
if
isinstance
(
data
,
basestring
):
course_id
,
image
=
data
,
None
elif
isinstance
(
data
,
dict
):
(
course_id
,
image
),
=
data
.
items
()
course_id
=
data
course_video
=
image
=
None
if
data
:
if
isinstance
(
data
,
dict
):
(
course_id
,
image
),
=
data
.
items
()
course_video
=
CourseVideo
(
course_id
=
course_id
)
course_video
.
full_clean
(
exclude
=
[
"video"
])
course_video
=
CourseVideo
(
course_id
=
course_id
)
course_video
.
full_clean
(
exclude
=
[
'video'
])
return
course_video
,
image
...
...
@@ -157,6 +158,10 @@ class VideoSerializer(serializers.ModelSerializer):
except
TypeError
:
raise
serializers
.
ValidationError
(
"profile field needs to be a profile_name (str)"
)
# Clean course_video list from any invalid data.
course_videos
=
[(
course_video
,
image
)
for
course_video
,
image
in
data
.
get
(
'courses'
,
[])
if
course_video
]
data
[
'courses'
]
=
course_videos
return
data
def
create
(
self
,
validated_data
):
...
...
edxval/tests/constants.py
View file @
fcd59d72
...
...
@@ -310,6 +310,14 @@ COMPLETE_SET_WITH_COURSE_KEY = dict(
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_WITH_SOME_INVALID_COURSE_KEY
=
dict
(
courses
=
[
None
,
False
,
''
,
'edX/DemoX/Astonomy'
],
encoded_videos
=
[
ENCODED_VIDEO_DICT_STAR
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_WITH_OTHER_COURSE_KEYS
=
dict
(
courses
=
[
'edX/DemoX/Astonomy'
,
'edX/DemoX/Zoology'
],
encoded_videos
=
[
...
...
edxval/tests/test_views.py
View file @
fcd59d72
...
...
@@ -2,6 +2,7 @@
"""
Tests for Video Abstraction Layer views
"""
import
json
from
ddt
import
ddt
,
data
,
unpack
from
django.core.urlresolvers
import
reverse
...
...
@@ -457,6 +458,19 @@ class VideoListTest(APIAuthTestCase):
self
.
assertEqual
(
len
(
video
),
1
)
self
.
assertEqual
(
len
(
video
[
0
]
.
get
(
"encoded_videos"
)),
0
)
def
test_post_video_invalid_course_key
(
self
):
"""
Tests POSTing a new Video with course video list containing some invalid course keys.
"""
url
=
reverse
(
'video-list'
)
response
=
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_WITH_SOME_INVALID_COURSE_KEY
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
response
=
json
.
loads
(
response
.
content
)
# Check that invalid course keys have been filtered out.
self
.
assertEqual
(
response
[
'courses'
],
[{
u'edX/DemoX/Astonomy'
:
None
}])
def
test_post_non_latin_client_video_id
(
self
):
"""
Tests POSTing non-latin client_video_id
...
...
setup.py
View file @
fcd59d72
...
...
@@ -39,7 +39,7 @@ def load_requirements(*requirements_paths):
setup
(
name
=
'edxval'
,
version
=
'0.0.1
6
'
,
version
=
'0.0.1
7
'
,
author
=
'edX'
,
url
=
'http://github.com/edx/edx-val'
,
description
=
'edx-val'
,
...
...
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