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
8f695d27
Commit
8f695d27
authored
Sep 19, 2017
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove external kwarg for import
parent
15a64aa5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
15 deletions
+10
-15
edxval/api.py
+7
-8
edxval/tests/test_api.py
+3
-7
No files found.
edxval/api.py
View file @
8f695d27
...
@@ -777,7 +777,7 @@ def create_transcripts_xml(video_ids, video_el):
...
@@ -777,7 +777,7 @@ def create_transcripts_xml(video_ids, video_el):
return
video_el
return
video_el
def
import_from_xml
(
xml
,
video_id
,
course_id
=
None
,
external
=
Fals
e
):
def
import_from_xml
(
xml
,
edx_video_id
,
course_id
=
Non
e
):
"""
"""
Imports data from a video_asset element about the given video_id.
Imports data from a video_asset element about the given video_id.
...
@@ -786,9 +786,8 @@ def import_from_xml(xml, video_id, course_id=None, external=False):
...
@@ -786,9 +786,8 @@ def import_from_xml(xml, video_id, course_id=None, external=False):
Arguments:
Arguments:
xml (Element): An lxml video_asset element containing import data
xml (Element): An lxml video_asset element containing import data
video_id (str): It can be an edx_video_id or empty string
edx_video_id (str): val video id
course_id (str): The ID of a course to associate the video with
course_id (str): The ID of a course to associate the video with
external (bool): False if `video_id` is an edx_video_id else True
Raises:
Raises:
ValCannotCreateError: if there is an error importing the video
ValCannotCreateError: if there is an error importing the video
...
@@ -797,15 +796,15 @@ def import_from_xml(xml, video_id, course_id=None, external=False):
...
@@ -797,15 +796,15 @@ def import_from_xml(xml, video_id, course_id=None, external=False):
raise
ValCannotCreateError
(
'Invalid XML'
)
raise
ValCannotCreateError
(
'Invalid XML'
)
# if edx_video_id does not exist then create video transcripts only
# if edx_video_id does not exist then create video transcripts only
if
external
:
if
not
edx_video_id
:
return
create_transcript_objects
(
xml
)
return
create_transcript_objects
(
xml
)
# If video with edx_video_id already exists, associate it with the given course_id.
# If video with edx_video_id already exists, associate it with the given course_id.
try
:
try
:
video
=
Video
.
objects
.
get
(
edx_video_id
=
video_id
)
video
=
Video
.
objects
.
get
(
edx_video_id
=
edx_
video_id
)
logger
.
info
(
logger
.
info
(
"edx_video_id '
%
s' present in course '
%
s' not imported because it exists in VAL."
,
"edx_video_id '
%
s' present in course '
%
s' not imported because it exists in VAL."
,
video_id
,
edx_
video_id
,
course_id
,
course_id
,
)
)
if
course_id
:
if
course_id
:
...
@@ -827,7 +826,7 @@ def import_from_xml(xml, video_id, course_id=None, external=False):
...
@@ -827,7 +826,7 @@ def import_from_xml(xml, video_id, course_id=None, external=False):
# Video with edx_video_id did not exist, so create one from xml data.
# Video with edx_video_id did not exist, so create one from xml data.
data
=
{
data
=
{
'edx_video_id'
:
video_id
,
'edx_video_id'
:
edx_
video_id
,
'client_video_id'
:
xml
.
get
(
'client_video_id'
),
'client_video_id'
:
xml
.
get
(
'client_video_id'
),
'duration'
:
xml
.
get
(
'duration'
),
'duration'
:
xml
.
get
(
'duration'
),
'status'
:
'imported'
,
'status'
:
'imported'
,
...
@@ -841,7 +840,7 @@ def import_from_xml(xml, video_id, course_id=None, external=False):
...
@@ -841,7 +840,7 @@ def import_from_xml(xml, video_id, course_id=None, external=False):
except
Profile
.
DoesNotExist
:
except
Profile
.
DoesNotExist
:
logger
.
info
(
logger
.
info
(
"Imported edx_video_id '
%
s' contains unknown profile '
%
s'."
,
"Imported edx_video_id '
%
s' contains unknown profile '
%
s'."
,
video_id
,
edx_
video_id
,
profile_name
profile_name
)
)
continue
continue
...
...
edxval/tests/test_api.py
View file @
8f695d27
...
@@ -1231,7 +1231,7 @@ class ImportTest(TestCase):
...
@@ -1231,7 +1231,7 @@ class ImportTest(TestCase):
def
test_existing_video_with_invalid_course_id
(
self
):
def
test_existing_video_with_invalid_course_id
(
self
):
xml
=
self
.
make_import_xml
(
video_dict
=
constants
.
VIDEO_DICT_FISH
)
xml
=
self
.
make_import_xml
(
video_dict
=
constants
.
VIDEO_DICT_FISH
)
with
self
.
assertRaises
(
ValCannotCreateError
):
with
self
.
assertRaises
(
ValCannotCreateError
):
api
.
import_from_xml
(
xml
,
video_id
=
constants
.
VIDEO_DICT_FISH
[
"edx_video_id"
],
course_id
=
"x"
*
300
)
api
.
import_from_xml
(
xml
,
edx_
video_id
=
constants
.
VIDEO_DICT_FISH
[
"edx_video_id"
],
course_id
=
"x"
*
300
)
def
test_unknown_profile
(
self
):
def
test_unknown_profile
(
self
):
profile
=
"unknown_profile"
profile
=
"unknown_profile"
...
@@ -1304,18 +1304,14 @@ class ImportTest(TestCase):
...
@@ -1304,18 +1304,14 @@ class ImportTest(TestCase):
with
self
.
assertRaises
(
VideoTranscript
.
DoesNotExist
):
with
self
.
assertRaises
(
VideoTranscript
.
DoesNotExist
):
VideoTranscript
.
objects
.
get
(
video_id
=
external_video_id
)
VideoTranscript
.
objects
.
get
(
video_id
=
external_video_id
)
api
.
import_from_xml
(
xml
,
external_video_id
,
external
=
True
)
api
.
import_from_xml
(
xml
,
''
)
self
.
assert_transcripts
(
external_video_id
,
[
self
.
transcript_data1
,
self
.
transcript_data2
])
self
.
assert_transcripts
(
external_video_id
,
[
self
.
transcript_data1
,
self
.
transcript_data2
])
def
test_external_no_video_transcript
(
self
):
def
test_external_no_video_transcript
(
self
):
"""
"""
Verify that transcript import for external video working as expected when there is no transcript.
Verify that transcript import for external video working as expected when there is no transcript.
"""
"""
api
.
import_from_xml
(
api
.
import_from_xml
(
etree
.
fromstring
(
'<video_asset/>'
),
''
)
etree
.
fromstring
(
'<video_asset/>'
),
'does_not_exist_id'
,
external
=
True
)
self
.
assertEqual
(
self
.
assertEqual
(
VideoTranscript
.
objects
.
count
(),
VideoTranscript
.
objects
.
count
(),
0
0
...
...
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