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
982a21df
Commit
982a21df
authored
Aug 12, 2014
by
Dave St.Germain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for subtitles
parent
dd811f85
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
135 additions
and
22 deletions
+135
-22
edxval/tests/constants.py
+40
-8
edxval/tests/test_api.py
+3
-3
edxval/tests/test_serializers.py
+1
-1
edxval/tests/test_views.py
+91
-10
No files found.
edxval/tests/constants.py
View file @
982a21df
...
...
@@ -39,7 +39,8 @@ VIDEO_DICT_NEGATIVE_DURATION = dict(
client_video_id
=
"Thunder Cats S01E01"
,
duration
=-
111
,
edx_video_id
=
"thisis12char-thisis7"
,
encoded_videos
=
[]
encoded_videos
=
[],
subtitles
=
[]
)
VIDEO_DICT_BEE_INVALID
=
dict
(
client_video_id
=
"Barking Bee"
,
...
...
@@ -50,7 +51,8 @@ VIDEO_DICT_INVALID_ID = dict(
client_video_id
=
"SuperSloth"
,
duration
=
42
,
edx_video_id
=
"sloppy/sloth!!"
,
encoded_videos
=
[]
encoded_videos
=
[],
subtitles
=
[]
)
ENCODED_VIDEO_DICT_NEGATIVE_FILESIZE
=
dict
(
url
=
"http://www.meowmix.com"
,
...
...
@@ -69,13 +71,15 @@ VIDEO_DICT_NON_LATIN_TITLE = dict(
client_video_id
=
u"배고픈 햄스터"
,
duration
=
42
,
edx_video_id
=
"ID"
,
encoded_videos
=
[]
encoded_videos
=
[],
subtitles
=
[]
)
VIDEO_DICT_NON_LATIN_ID
=
dict
(
client_video_id
=
"Hungry Hamster"
,
duration
=
42
,
edx_video_id
=
"밥줘"
,
encoded_videos
=
[]
encoded_videos
=
[],
subtitles
=
[]
)
PROFILE_DICT_NON_LATIN
=
dict
(
profile_name
=
u"배고파"
,
...
...
@@ -112,6 +116,19 @@ PROFILE_DICT_MANY_INVALID = dict(
height
=
"lol"
,
)
"""
Subtitles
"""
SUBTITLE_DICT_SRT
=
dict
(
fmt
=
"srt"
,
language
=
"en"
,
content
=
"0:0:0
\n
hello"
)
SUBTITLE_DICT_SJSON
=
dict
(
fmt
=
"sjson"
,
language
=
"fr"
,
content
=
'{"start": "00:00:00"}'
)
"""
Fish
"""
VIDEO_DICT_FISH
=
dict
(
...
...
@@ -159,6 +176,7 @@ COMPLETE_SET_FISH = dict(
ENCODED_VIDEO_DICT_FISH_MOBILE
,
ENCODED_VIDEO_DICT_FISH_DESKTOP
],
subtitles
=
[
SUBTITLE_DICT_SRT
,
SUBTITLE_DICT_SJSON
],
**
VIDEO_DICT_FISH
)
COMPLETE_SET_TWO_MOBILE_FISH
=
dict
(
...
...
@@ -166,6 +184,7 @@ COMPLETE_SET_TWO_MOBILE_FISH = dict(
ENCODED_VIDEO_DICT_FISH_MOBILE
,
ENCODED_VIDEO_DICT_FISH_MOBILE
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_FISH
)
COMPLETE_SET_UPDATE_FISH
=
dict
(
...
...
@@ -173,6 +192,7 @@ COMPLETE_SET_UPDATE_FISH = dict(
ENCODED_VIDEO_DICT_UPDATE_FISH_MOBILE
,
ENCODED_VIDEO_DICT_UPDATE_FISH_DESKTOP
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_FISH
)
COMPLETE_SET_DIFFERENT_ID_UPDATE_FISH
=
dict
(
...
...
@@ -180,6 +200,7 @@ COMPLETE_SET_DIFFERENT_ID_UPDATE_FISH = dict(
ENCODED_VIDEO_DICT_UPDATE_FISH_MOBILE
,
ENCODED_VIDEO_DICT_UPDATE_FISH_DESKTOP
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_DIFFERENT_ID_FISH
)
COMPLETE_SET_FIRST_HALF_UPDATE_FISH
=
dict
(
...
...
@@ -187,12 +208,14 @@ COMPLETE_SET_FIRST_HALF_UPDATE_FISH = dict(
ENCODED_VIDEO_DICT_UPDATE_FISH_MOBILE
,
ENCODED_VIDEO_DICT_FISH_DESKTOP
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_FISH
)
COMPLETE_SET_UPDATE_ONLY_DESKTOP_FISH
=
dict
(
encoded_videos
=
[
ENCODED_VIDEO_DICT_UPDATE_FISH_DESKTOP
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_FISH
)
COMPLETE_SET_INVALID_ENCODED_VIDEO_FISH
=
dict
(
...
...
@@ -200,6 +223,7 @@ COMPLETE_SET_INVALID_ENCODED_VIDEO_FISH = dict(
ENCODED_VIDEO_DICT_FISH_MOBILE
,
ENCODED_VIDEO_DICT_FISH_INVALID_PROFILE
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_FISH
)
COMPLETE_SET_INVALID_VIDEO_FISH
=
dict
(
...
...
@@ -209,7 +233,8 @@ COMPLETE_SET_INVALID_VIDEO_FISH = dict(
encoded_videos
=
[
ENCODED_VIDEO_DICT_FISH_MOBILE
,
ENCODED_VIDEO_DICT_FISH_DESKTOP
]
],
subtitles
=
[
SUBTITLE_DICT_SRT
]
)
COMPLETE_SETS_ALL_INVALID
=
[
...
...
@@ -240,12 +265,14 @@ COMPLETE_SET_STAR = dict(
encoded_videos
=
[
ENCODED_VIDEO_DICT_STAR
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_UPDATE_STAR
=
dict
(
encoded_videos
=
[
ENCODED_VIDEO_UPDATE_DICT_STAR
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_NOT_A_LIST
=
dict
(
...
...
@@ -255,6 +282,7 @@ COMPLETE_SET_NOT_A_LIST = dict(
bitrate
=
42
,
profile
=
1
),
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_EXTRA_VIDEO_FIELD
=
dict
(
...
...
@@ -267,6 +295,7 @@ COMPLETE_SET_EXTRA_VIDEO_FIELD = dict(
video
=
"This should be overridden by parent video field"
)
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
"""
...
...
@@ -276,17 +305,20 @@ VIDEO_DICT_ZEBRA = dict(
client_video_id
=
"Zesty Zebra"
,
duration
=
111.00
,
edx_video_id
=
"zestttt"
,
encoded_videos
=
[]
encoded_videos
=
[],
subtitles
=
[]
)
VIDEO_DICT_ANIMAL
=
dict
(
client_video_id
=
"Average Animal"
,
duration
=
111.00
,
edx_video_id
=
"mediocrity"
,
encoded_videos
=
[]
encoded_videos
=
[],
subtitles
=
[]
)
VIDEO_DICT_UPDATE_ANIMAL
=
dict
(
client_video_id
=
"Above Average Animal"
,
duration
=
999.00
,
edx_video_id
=
"mediocrity"
,
encoded_videos
=
[]
encoded_videos
=
[],
subtitles
=
[]
)
edxval/tests/test_api.py
View file @
982a21df
...
...
@@ -225,7 +225,7 @@ class GetVideoInfoTestWithHttpCalls(APITestCase):
"""
Tests number of queries for a Video/EncodedVideo(1) pair
"""
with
self
.
assertNumQueries
(
4
):
with
self
.
assertNumQueries
(
5
):
api
.
get_video_info
(
constants
.
COMPLETE_SET_FISH
.
get
(
"edx_video_id"
))
def
test_get_info_queries_for_one_encoded_video
(
self
):
...
...
@@ -237,7 +237,7 @@ class GetVideoInfoTestWithHttpCalls(APITestCase):
url
,
constants
.
COMPLETE_SET_STAR
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
with
self
.
assertNumQueries
(
3
):
with
self
.
assertNumQueries
(
4
):
api
.
get_video_info
(
constants
.
COMPLETE_SET_STAR
.
get
(
"edx_video_id"
))
def
test_get_info_queries_for_only_video
(
self
):
...
...
@@ -249,6 +249,6 @@ class GetVideoInfoTestWithHttpCalls(APITestCase):
url
,
constants
.
VIDEO_DICT_ZEBRA
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
with
self
.
assertNumQueries
(
2
):
with
self
.
assertNumQueries
(
3
):
api
.
get_video_info
(
constants
.
VIDEO_DICT_ZEBRA
.
get
(
"edx_video_id"
))
edxval/tests/test_serializers.py
View file @
982a21df
...
...
@@ -58,7 +58,7 @@ class SerializerTests(TestCase):
"""
Tests if the serializers can accept non-latin chars
"""
#TODO not the best test. Need to understand what result we want
#
TODO not the best test. Need to understand what result we want
self
.
assertIsInstance
(
ProfileSerializer
(
Profile
.
objects
.
get
(
profile_name
=
"배고파"
)),
ProfileSerializer
...
...
edxval/tests/test_views.py
View file @
982a21df
# pylint: disable=E1103, W0106
# pylint: disable=E1103, W0106
"""
Tests for Video Abstraction Layer views
"""
...
...
@@ -22,7 +22,7 @@ class VideoDetail(APITestCase):
Profile
.
objects
.
create
(
**
constants
.
PROFILE_DICT_MOBILE
)
Profile
.
objects
.
create
(
**
constants
.
PROFILE_DICT_DESKTOP
)
#Tests for successful PUT requests.
#
Tests for successful PUT requests.
def
test_update_video
(
self
):
"""
...
...
@@ -216,7 +216,7 @@ class VideoDetail(APITestCase):
constants
.
ENCODED_VIDEO_DICT_UPDATE_FISH_DESKTOP
.
get
(
"url"
)
)
#Tests for bad PUT requests.
#
Tests for bad PUT requests.
def
test_update_an_invalid_encoded_videos
(
self
):
"""
...
...
@@ -304,7 +304,7 @@ class VideoListTest(APITestCase):
def
test_complete_set_two_encoded_video_post
(
self
):
"""
Tests POSTing Video and EncodedVideo pair
"""
#
pylint: disable=R0801
"""
#
pylint: disable=R0801
url
=
reverse
(
'video-list'
)
response
=
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_FISH
,
format
=
'json'
...
...
@@ -434,7 +434,7 @@ class VideoListTest(APITestCase):
Tests number of queries for a Video with no Encoded Videos
"""
url
=
reverse
(
'video-list'
)
with
self
.
assertNumQueries
(
3
):
with
self
.
assertNumQueries
(
4
):
self
.
client
.
post
(
url
,
constants
.
VIDEO_DICT_ZEBRA
,
format
=
'json'
)
def
test_queries_for_two_encoded_video
(
self
):
...
...
@@ -442,7 +442,7 @@ class VideoListTest(APITestCase):
Tests number of queries for a Video/EncodedVideo(2) pair
"""
url
=
reverse
(
'video-list'
)
with
self
.
assertNumQueries
(
1
1
):
with
self
.
assertNumQueries
(
1
4
):
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_FISH
,
format
=
'json'
)
def
test_queries_for_single_encoded_videos
(
self
):
...
...
@@ -450,7 +450,7 @@ class VideoListTest(APITestCase):
Tests number of queries for a Video/EncodedVideo(1) pair
"""
url
=
reverse
(
'video-list'
)
with
self
.
assertNumQueries
(
7
):
with
self
.
assertNumQueries
(
9
):
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_STAR
,
format
=
'json'
)
...
...
@@ -486,13 +486,94 @@ class VideoDetailTest(APITestCase):
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
response
=
self
.
client
.
post
(
url
,
constants
.
VIDEO_DICT_ZEBRA
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
with
self
.
assertNumQueries
(
2
):
with
self
.
assertNumQueries
(
4
):
self
.
client
.
get
(
"/edxval/video/"
)
.
data
response
=
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_FISH
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
with
self
.
assertNumQueries
(
4
):
with
self
.
assertNumQueries
(
7
):
self
.
client
.
get
(
"/edxval/video/"
)
.
data
response
=
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_STAR
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
with
self
.
assertNumQueries
(
5
):
with
self
.
assertNumQueries
(
9
):
self
.
client
.
get
(
"/edxval/video/"
)
.
data
class
SubtitleDetailTest
(
APITestCase
):
"""
Tests for subtitle API
"""
def
setUp
(
self
):
Profile
.
objects
.
create
(
**
constants
.
PROFILE_DICT_MOBILE
)
Profile
.
objects
.
create
(
**
constants
.
PROFILE_DICT_DESKTOP
)
def
test_get_subtitle_content
(
self
):
"""
Get subtitle content
"""
url
=
reverse
(
'video-list'
)
response
=
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_FISH
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
video
=
self
.
client
.
get
(
"/edxval/video/"
)
.
data
self
.
assertEqual
(
len
(
video
),
1
)
self
.
assertEqual
(
len
(
video
[
0
]
.
get
(
"subtitles"
)),
2
)
st
=
video
[
0
][
'subtitles'
][
0
]
response
=
self
.
client
.
get
(
st
[
'content_url'
])
self
.
assertEqual
(
response
.
content
,
constants
.
SUBTITLE_DICT_SRT
[
'content'
])
self
.
assertEqual
(
response
[
'Content-Type'
],
'text/plain'
)
st
=
video
[
0
][
'subtitles'
][
1
]
response
=
self
.
client
.
get
(
st
[
'content_url'
])
self
.
assertEqual
(
response
.
content
,
constants
.
SUBTITLE_DICT_SJSON
[
'content'
])
self
.
assertEqual
(
response
[
'Content-Type'
],
'application/json'
)
def
test_update_subtitle
(
self
):
"""
Update an SRT subtitle
"""
url
=
reverse
(
'video-list'
)
response
=
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_FISH
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
video
=
response
.
data
st
=
video
[
'subtitles'
][
0
]
url
=
reverse
(
'subtitle-detail'
,
kwargs
=
{
'id'
:
st
[
'id'
]})
st
[
'content'
]
=
'testing 123'
response
=
self
.
client
.
put
(
url
,
st
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
self
.
client
.
get
(
st
[
'content_url'
])
.
content
,
'testing 123'
)
def
test_update_json_subtitle
(
self
):
"""
Update a JSON subtitle
"""
url
=
reverse
(
'video-list'
)
response
=
self
.
client
.
post
(
url
,
constants
.
COMPLETE_SET_FISH
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
video
=
response
.
data
st
=
video
[
'subtitles'
][
1
]
url
=
reverse
(
'subtitle-detail'
,
kwargs
=
{
'id'
:
st
[
'id'
]})
st
[
'content'
]
=
'testing 123'
response
=
self
.
client
.
put
(
url
,
st
,
format
=
'json'
)
# not in json format
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
st
[
'content'
]
=
"""{"start": "00:00:00"
}"""
response
=
self
.
client
.
put
(
url
,
st
,
format
=
'json'
)
self
.
assertEqual
(
self
.
client
.
get
(
st
[
'content_url'
])
.
content
,
'{"start": "00:00:00"}'
)
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