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
f7c9245a
Commit
f7c9245a
authored
May 17, 2017
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address feedback
parent
46671d8e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
edxval/api.py
+5
-4
edxval/tests/test_api.py
+20
-3
No files found.
edxval/api.py
View file @
f7c9245a
...
...
@@ -174,7 +174,10 @@ def update_video_image(edx_video_id, course_id, image_data, file_name):
course_id
=
course_id
,
video__edx_video_id
=
edx_video_id
)
except
ObjectDoesNotExist
:
error_message
=
u'CourseVideo not found for edx_video_id: {0}'
.
format
(
edx_video_id
)
error_message
=
u'VAL: CourseVideo not found for edx_video_id: {0} and course_id: {1}'
.
format
(
edx_video_id
,
course_id
)
raise
ValVideoNotFoundError
(
error_message
)
video_image
,
_
=
VideoImage
.
create_or_update
(
course_video
,
file_name
,
image_data
)
...
...
@@ -490,13 +493,11 @@ def copy_course_videos(source_course_id, destination_course_id):
video
=
course_video
.
video
,
course_id
=
destination_course_id
)
try
:
if
hasattr
(
course_video
,
'video_image'
)
:
VideoImage
.
create_or_update
(
course_video
=
destination_course_video
,
file_name
=
course_video
.
video_image
.
image
.
name
)
except
VideoImage
.
DoesNotExist
:
pass
def
export_to_xml
(
edx_video_id
,
course_id
=
None
):
...
...
edxval/tests/test_api.py
View file @
f7c9245a
...
...
@@ -1227,12 +1227,12 @@ class VideoStatusUpdateTest(TestCase):
class
CourseVideoImageTest
(
TestCase
):
"""
Tests to check course video image related functions works correctly
Tests to check course video image related functions works correctly
.
"""
def
setUp
(
self
):
"""
Creates video objects for courses
Creates video objects for courses
.
"""
self
.
course_id
=
'test-course'
self
.
course_id2
=
'test-course2'
...
...
@@ -1308,7 +1308,7 @@ class CourseVideoImageTest(TestCase):
@patch
(
'edxval.models.logger'
)
def
test_create_or_update_logging
(
self
,
mock_logger
):
"""
Tests correct message is logged when save to storge is failed in `create_or_update`
Tests correct message is logged when save to storge is failed in `create_or_update`
.
"""
with
self
.
assertRaises
(
Exception
)
as
save_exception
:
# pylint: disable=unused-variable
VideoImage
.
create_or_update
(
self
.
course_video
,
'test.jpg'
,
open
(
self
.
image_path2
))
...
...
@@ -1318,3 +1318,20 @@ class CourseVideoImageTest(TestCase):
self
.
course_video
.
course_id
,
self
.
course_video
.
video
.
edx_video_id
)
def
test_update_video_image_exception
(
self
):
"""
Tests exception message when we hit by an exception in `update_video_image`.
"""
does_not_course_id
=
'does_not_exist'
with
self
.
assertRaises
(
Exception
)
as
get_exception
:
api
.
update_video_image
(
self
.
edx_video_id
,
does_not_course_id
,
open
(
self
.
image_path2
),
'test.jpg'
)
self
.
assertEqual
(
get_exception
.
exception
.
message
,
u'VAL: CourseVideo not found for edx_video_id: {0} and course_id: {1}'
.
format
(
self
.
edx_video_id
,
does_not_course_id
)
)
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