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
3a28c570
Commit
3a28c570
authored
Feb 13, 2015
by
Martyn James
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6896 from edx/mjevtic/fixing-video-module-tests-for-search
Fixed a test_video issue regarding settings
parents
5d4e84eb
f444d9b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
85 deletions
+100
-85
common/lib/xmodule/xmodule/tests/test_video.py
+100
-85
No files found.
common/lib/xmodule/xmodule/tests/test_video.py
View file @
3a28c570
...
...
@@ -29,7 +29,6 @@ from xmodule.tests import get_test_descriptor_system
from
xmodule.video_module.transcripts_utils
import
download_youtube_subs
,
save_to_store
from
django.conf
import
settings
from
django.test.utils
import
override_settings
SRT_FILEDATA
=
'''
0
...
...
@@ -51,38 +50,29 @@ Dobar dan!
Kako ste danas?
'''
TEST_YOU_TUBE_SETTINGS
=
{
# YouTube JavaScript API
'API'
:
'www.youtube.com/iframe_api'
,
# URL to test YouTube availability
'TEST_URL'
:
'gdata.youtube.com/feeds/api/videos/'
,
# Current youtube api for requesting transcripts.
# For example: http://video.google.com/timedtext?lang=en&v=j_jEn79vS3g.
'TEXT_API'
:
{
'url'
:
'video.google.com/timedtext'
,
'params'
:
{
'lang'
:
'en'
,
'v'
:
'set_youtube_id_of_11_symbols_here'
,
},
},
}
TEST_DATA_CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'DOC_STORE_CONFIG'
:
{
'host'
:
'localhost'
,
'db'
:
'test_xcontent_
%
s'
%
uuid4
()
.
hex
,
},
# allow for additional options that can be keyed on a name, e.g. 'trashcan'
'ADDITIONAL_OPTIONS'
:
{
'trashcan'
:
{
'bucket'
:
'trash_fs'
}
}
}
YOUTUBE_SUBTITLES
=
(
"LILA FISHER: Hi, welcome to Edx. I'm Lila Fisher, an Edx fellow helping to put together these"
" courses. As you know, our courses are entirely online. So before we start learning about the"
" subjects that brought you here, let's learn about the tools that you will use to navigate through"
" the course material. Let's start with what is on your screen right now. You are watching a video"
" of me talking. You have several tools associated with these videos. Some of them are standard"
" video buttons, like the play Pause Button on the bottom left. Like most video players, you can see"
" how far you are into this particular video segment and how long the entire video segment is."
" Something that you might not be used to is the speed option. While you are going through the"
" videos, you can speed up or slow down the video player with these buttons. Go ahead and try that"
" now. Make me talk faster and slower. If you ever get frustrated by the pace of speech, you can"
" adjust it this way. Another great feature is the transcript on the side. This will follow along"
" with everything that I am saying as I am saying it, so you can read along if you like. You can"
" also click on any of the words, and you will notice that the video jumps to that word. The video"
" slider at the bottom of the video will let you navigate through the video quickly. If you ever"
" find the transcript distracting, you can toggle the captioning button in order to make it go away"
" or reappear. Now that you know about the video player, I want to point out the sequence navigator."
" Right now you're in a lecture sequence, which interweaves many videos and practice exercises. You"
" can see how far you are in a particular sequence by observing which tab you're on. You can"
" navigate directly to any video or exercise by clicking on the appropriate tab. You can also"
" progress to the next element by pressing the Arrow button, or by clicking on the next tab. Try"
" that now. The tutorial will continue in the next video."
)
def
instantiate_descriptor
(
**
field_data
):
...
...
@@ -130,7 +120,6 @@ class VideoModuleTest(LogicTest):
def
test_parse_youtube_invalid
(
self
):
"""Ensure that ids that are invalid return an empty dict"""
# invalid id
youtube_str
=
'thisisaninvalidid'
output
=
VideoDescriptor
.
_parse_youtube
(
youtube_str
)
...
...
@@ -183,7 +172,6 @@ class VideoDescriptorTestBase(unittest.TestCase):
"""
Base class for tests for VideoDescriptor
"""
def
setUp
(
self
):
super
(
VideoDescriptorTestBase
,
self
)
.
setUp
()
self
.
descriptor
=
instantiate_descriptor
()
...
...
@@ -646,14 +634,70 @@ class VideoCdnTest(unittest.TestCase):
self
.
assertIsNone
(
get_video_from_cdn
(
fake_cdn_url
,
original_video_url
))
@override_settings
(
CONTENTSTORE
=
TEST_DATA_CONTENTSTORE
)
@override_settings
(
YOUTUBE
=
TEST_YOU_TUBE_SETTINGS
)
class
VideoDescriptorIndexingTestCase
(
unittest
.
TestCase
):
"""
Make sure that VideoDescriptor can format data for indexing as expected.
"""
def
setUp
(
self
):
"""
Overrides YOUTUBE and CONTENTSTORE settings
"""
self
.
youtube_setting
=
getattr
(
settings
,
"YOUTUBE"
,
None
)
self
.
contentstore_setting
=
getattr
(
settings
,
"CONTENTSTORE"
,
None
)
settings
.
YOUTUBE
=
{
# YouTube JavaScript API
'API'
:
'www.youtube.com/iframe_api'
,
# URL to test YouTube availability
'TEST_URL'
:
'gdata.youtube.com/feeds/api/videos/'
,
# Current youtube api for requesting transcripts.
# For example: http://video.google.com/timedtext?lang=en&v=j_jEn79vS3g.
'TEXT_API'
:
{
'url'
:
'video.google.com/timedtext'
,
'params'
:
{
'lang'
:
'en'
,
'v'
:
'set_youtube_id_of_11_symbols_here'
,
},
},
}
def
test_index_dictionary
(
self
):
settings
.
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'DOC_STORE_CONFIG'
:
{
'host'
:
'localhost'
,
'db'
:
'test_xcontent_
%
s'
%
uuid4
()
.
hex
,
},
# allow for additional options that can be keyed on a name, e.g. 'trashcan'
'ADDITIONAL_OPTIONS'
:
{
'trashcan'
:
{
'bucket'
:
'trash_fs'
}
}
}
self
.
addCleanup
(
self
.
cleanup
)
def
cleanup
(
self
):
"""
Returns YOUTUBE and CONTENTSTORE settings to a default value
"""
if
self
.
youtube_setting
:
settings
.
YOUTUBE
=
self
.
youtube_setting
self
.
youtube_setting
=
None
else
:
del
settings
.
YOUTUBE
if
self
.
contentstore_setting
:
settings
.
CONTENTSTORE
=
self
.
contentstore_setting
self
.
contentstore_setting
=
None
else
:
del
settings
.
CONTENTSTORE
def
test_video_with_no_subs_index_dictionary
(
self
):
"""
Test index dictionary of a video module without subtitles.
"""
xml_data
=
'''
<video display_name="Test Video"
youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
...
...
@@ -673,6 +717,10 @@ class VideoDescriptorIndexingTestCase(unittest.TestCase):
"content_type"
:
"Video"
})
def
test_video_with_youtube_subs_index_dictionary
(
self
):
"""
Test index dictionary of a video module with YouTube subtitles.
"""
xml_data_sub
=
'''
<video display_name="Test Video"
youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
...
...
@@ -693,33 +741,16 @@ class VideoDescriptorIndexingTestCase(unittest.TestCase):
self
.
assertEqual
(
descriptor
.
index_dictionary
(),
{
"content"
:
{
"display_name"
:
"Test Video"
,
"transcript_en"
:
(
"LILA FISHER: Hi, welcome to Edx. I'm Lila Fisher, an Edx fellow helping to put together these"
"courses. As you know, our courses are entirely online. So before we start learning about the"
"subjects that brought you here, let's learn about the tools that you will use to navigate through"
"the course material. Let's start with what is on your screen right now. You are watching a video"
"of me talking. You have several tools associated with these videos. Some of them are standard"
"video buttons, like the play Pause Button on the bottom left. Like most video players, you can see"
"how far you are into this particular video segment and how long the entire video segment is."
"Something that you might not be used to is the speed option. While you are going through the"
"videos, you can speed up or slow down the video player with these buttons. Go ahead and try that"
"now. Make me talk faster and slower. If you ever get frustrated by the pace of speech, you can"
"adjust it this way. Another great feature is the transcript on the side. This will follow along"
"with everything that I am saying as I am saying it, so you can read along if you like. You can"
"also click on any of the words, and you will notice that the video jumps to that word. The video"
"slider at the bottom of the video will let you navigate through the video quickly. If you ever"
"find the transcript distracting, you can toggle the captioning button in order to make it go away"
"or reappear. Now that you know about the video player, I want to point out the sequence navigator."
"Right now you're in a lecture sequence, which interweaves many videos and practice exercises. You"
"can see how far you are in a particular sequence by observing which tab you're on. You can"
"navigate directly to any video or exercise by clicking on the appropriate tab. You can also"
"progress to the next element by pressing the Arrow button, or by clicking on the next tab. Try"
"that now. The tutorial will continue in the next video."
)
"transcript_en"
:
YOUTUBE_SUBTITLES
},
"content_type"
:
"Video"
})
def
test_video_with_subs_and_transcript_index_dictionary
(
self
):
"""
Test index dictionary of a video module with
YouTube subtitles and German transcript uploaded by a user.
"""
xml_data_sub_transcript
=
'''
<video display_name="Test Video"
youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
...
...
@@ -737,38 +768,22 @@ class VideoDescriptorIndexingTestCase(unittest.TestCase):
'''
descriptor
=
instantiate_descriptor
(
data
=
xml_data_sub_transcript
)
download_youtube_subs
(
'OEoXaMPEzfM'
,
descriptor
,
settings
)
save_to_store
(
SRT_FILEDATA
,
"subs_grmtran1.srt"
,
'text/srt'
,
descriptor
.
location
)
self
.
assertEqual
(
descriptor
.
index_dictionary
(),
{
"content"
:
{
"display_name"
:
"Test Video"
,
"transcript_en"
:
(
"LILA FISHER: Hi, welcome to Edx. I'm Lila Fisher, an Edx fellow helping to put together these"
"courses. As you know, our courses are entirely online. So before we start learning about the"
"subjects that brought you here, let's learn about the tools that you will use to navigate through"
"the course material. Let's start with what is on your screen right now. You are watching a video"
"of me talking. You have several tools associated with these videos. Some of them are standard"
"video buttons, like the play Pause Button on the bottom left. Like most video players, you can see"
"how far you are into this particular video segment and how long the entire video segment is."
"Something that you might not be used to is the speed option. While you are going through the"
"videos, you can speed up or slow down the video player with these buttons. Go ahead and try that"
"now. Make me talk faster and slower. If you ever get frustrated by the pace of speech, you can"
"adjust it this way. Another great feature is the transcript on the side. This will follow along"
"with everything that I am saying as I am saying it, so you can read along if you like. You can"
"also click on any of the words, and you will notice that the video jumps to that word. The video"
"slider at the bottom of the video will let you navigate through the video quickly. If you ever"
"find the transcript distracting, you can toggle the captioning button in order to make it go away"
"or reappear. Now that you know about the video player, I want to point out the sequence navigator."
"Right now you're in a lecture sequence, which interweaves many videos and practice exercises. You"
"can see how far you are in a particular sequence by observing which tab you're on. You can"
"navigate directly to any video or exercise by clicking on the appropriate tab. You can also"
"progress to the next element by pressing the Arrow button, or by clicking on the next tab. Try"
"that now. The tutorial will continue in the next video."
),
"transcript_ge"
:
"sprechen sie deutsch? Ja, ich spreche Deutsch"
"transcript_en"
:
YOUTUBE_SUBTITLES
,
"transcript_ge"
:
"sprechen sie deutsch? Ja, ich spreche Deutsch"
,
},
"content_type"
:
"Video"
})
def
test_video_with_multiple_transcripts_index_dictionary
(
self
):
"""
Test index dictionary of a video module with
two transcripts uploaded by a user.
"""
xml_data_transcripts
=
'''
<video display_name="Test Video"
youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
...
...
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