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
dccf16fb
Commit
dccf16fb
authored
Jun 16, 2017
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto generated images fixes
parent
70842122
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
14 deletions
+29
-14
edxval/tests/test_views.py
+25
-11
edxval/views.py
+3
-2
setup.py
+1
-1
No files found.
edxval/tests/test_views.py
View file @
dccf16fb
...
@@ -808,8 +808,10 @@ class VideoImagesViewTest(APIAuthTestCase):
...
@@ -808,8 +808,10 @@ class VideoImagesViewTest(APIAuthTestCase):
Used for manually creating profile objects which EncodedVideos require.
Used for manually creating profile objects which EncodedVideos require.
"""
"""
self
.
course_id
=
'test_course_id'
self
.
course_id
=
'test_course_id'
self
.
video
=
Video
.
objects
.
create
(
**
constants
.
VIDEO_DICT_FISH
)
self
.
video1
=
Video
.
objects
.
create
(
**
constants
.
VIDEO_DICT_FISH
)
self
.
course_video
=
CourseVideo
.
objects
.
create
(
video
=
self
.
video
,
course_id
=
self
.
course_id
)
self
.
video2
=
Video
.
objects
.
create
(
**
constants
.
VIDEO_DICT_DIFFERENT_ID_FISH
)
self
.
course_video1
=
CourseVideo
.
objects
.
create
(
video
=
self
.
video1
,
course_id
=
self
.
course_id
)
self
.
course_video2
=
CourseVideo
.
objects
.
create
(
video
=
self
.
video2
,
course_id
=
self
.
course_id
)
super
(
VideoImagesViewTest
,
self
)
.
setUp
()
super
(
VideoImagesViewTest
,
self
)
.
setUp
()
def
test_update_auto_generated_images
(
self
):
def
test_update_auto_generated_images
(
self
):
...
@@ -820,39 +822,51 @@ class VideoImagesViewTest(APIAuthTestCase):
...
@@ -820,39 +822,51 @@ class VideoImagesViewTest(APIAuthTestCase):
url
=
reverse
(
'update-video-images'
)
url
=
reverse
(
'update-video-images'
)
response
=
self
.
client
.
post
(
response
=
self
.
client
.
post
(
url
,
url
,
{
'course_id'
:
self
.
course_id
,
'generated_images'
:
generated_images
},
{
'course_id'
:
self
.
course_id
,
'edx_video_id'
:
self
.
video1
.
edx_video_id
,
'generated_images'
:
generated_images
},
format
=
'json'
format
=
'json'
)
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
self
.
course_video
.
video_image
.
image
.
name
,
generated_images
[
0
])
self
.
assertEqual
(
self
.
course_video
1
.
video_image
.
image
.
name
,
generated_images
[
0
])
self
.
assertEqual
(
self
.
course_video
.
video_image
.
generated_images
,
generated_images
)
self
.
assertEqual
(
self
.
course_video
1
.
video_image
.
generated_images
,
generated_images
)
# verify that if we post again then `VideoImage.image.name` should not be updated
# verify that if we post again then `VideoImage.image.name` should not be updated
# but `VideoImage.generated_images` should be updated with new names.
# but `VideoImage.generated_images` should be updated with new names.
new_generated_images
=
[
'a.png'
,
'b.png'
,
'c.png'
]
new_generated_images
=
[
'a.png'
,
'b.png'
,
'c.png'
]
response
=
self
.
client
.
post
(
response
=
self
.
client
.
post
(
url
,
url
,
{
'course_id'
:
self
.
course_id
,
'generated_images'
:
new_generated_images
},
{
'course_id'
:
self
.
course_id
,
'edx_video_id'
:
self
.
video1
.
edx_video_id
,
'generated_images'
:
new_generated_images
},
format
=
'json'
format
=
'json'
)
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
self
.
course_video
.
video_image
.
image
.
name
,
generated_images
[
0
])
self
.
assertEqual
(
self
.
course_video
1
.
video_image
.
image
.
name
,
generated_images
[
0
])
course_video
=
CourseVideo
.
objects
.
get
(
video
=
self
.
video
,
course_id
=
self
.
course_id
)
course_video
=
CourseVideo
.
objects
.
get
(
video
=
self
.
video
1
,
course_id
=
self
.
course_id
)
self
.
assertEqual
(
course_video
.
video_image
.
generated_images
,
new_generated_images
)
self
.
assertEqual
(
course_video
.
video_image
.
generated_images
,
new_generated_images
)
@data
(
@data
(
{
{
'post_data'
:
{},
'post_data'
:
{},
'message'
:
u'course_id and generated_images must be specified to update a video image.'
'message'
:
u'course_id and
edx_video_id and
generated_images must be specified to update a video image.'
},
},
{
{
'post_data'
:
{
'course_id'
:
'does_not_exit_course'
,
'generated_images'
:
[]},
'post_data'
:
{
'course_id'
:
'does_not_exit_course'
,
'
edx_video_id'
:
'super-soaker'
,
'
generated_images'
:
[]},
'message'
:
u'CourseVideo not found for course_id: does_not_exit_course'
'message'
:
u'CourseVideo not found for course_id: does_not_exit_course'
},
},
{
{
'post_data'
:
{
'course_id'
:
'test_course_id'
,
'generated_images'
:
[
1
,
2
,
3
]},
'post_data'
:
{
'course_id'
:
'test_course_id'
,
'edx_video_id'
:
'does_not_exit_video'
,
'generated_images'
:
[]},
'message'
:
u'CourseVideo not found for course_id: test_course_id'
},
{
'post_data'
:
{
'course_id'
:
'test_course_id'
,
'edx_video_id'
:
'super-soaker'
,
'generated_images'
:
[
1
,
2
,
3
]},
'message'
:
"[u'list must only contain strings.']"
'message'
:
"[u'list must only contain strings.']"
},
},
)
)
...
...
edxval/views.py
View file @
dccf16fb
...
@@ -113,7 +113,7 @@ class VideoImagesView(APIView):
...
@@ -113,7 +113,7 @@ class VideoImagesView(APIView):
"""
"""
Update a course video image instance with auto generated image names.
Update a course video image instance with auto generated image names.
"""
"""
attrs
=
(
'course_id'
,
'generated_images'
)
attrs
=
(
'course_id'
,
'
edx_video_id'
,
'
generated_images'
)
missing
=
[
attr
for
attr
in
attrs
if
attr
not
in
request
.
data
]
missing
=
[
attr
for
attr
in
attrs
if
attr
not
in
request
.
data
]
if
missing
:
if
missing
:
return
Response
(
return
Response
(
...
@@ -126,11 +126,12 @@ class VideoImagesView(APIView):
...
@@ -126,11 +126,12 @@ class VideoImagesView(APIView):
)
)
course_id
=
request
.
data
[
'course_id'
]
course_id
=
request
.
data
[
'course_id'
]
edx_video_id
=
request
.
data
[
'edx_video_id'
]
generated_images
=
request
.
data
[
'generated_images'
]
generated_images
=
request
.
data
[
'generated_images'
]
try
:
try
:
course_video
=
CourseVideo
.
objects
.
select_related
(
'video_image'
)
.
get
(
course_video
=
CourseVideo
.
objects
.
select_related
(
'video_image'
)
.
get
(
course_id
=
unicode
(
course_id
)
course_id
=
unicode
(
course_id
)
,
video__edx_video_id
=
edx_video_id
)
)
except
CourseVideo
.
DoesNotExist
:
except
CourseVideo
.
DoesNotExist
:
return
Response
(
return
Response
(
...
...
setup.py
View file @
dccf16fb
...
@@ -39,7 +39,7 @@ def load_requirements(*requirements_paths):
...
@@ -39,7 +39,7 @@ def load_requirements(*requirements_paths):
setup
(
setup
(
name
=
'edxval'
,
name
=
'edxval'
,
version
=
'0.0.1
5
'
,
version
=
'0.0.1
6
'
,
author
=
'edX'
,
author
=
'edX'
,
url
=
'http://github.com/edx/edx-val'
,
url
=
'http://github.com/edx/edx-val'
,
description
=
'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