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
1ed30a30
Commit
1ed30a30
authored
Oct 26, 2017
by
Muzaffar yousaf
Committed by
GitHub
Oct 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #106 from edx/remove-subtitles
Remove subtitles code from VAL.
parents
adc76966
4b7f0f2e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
188 deletions
+24
-188
edxval/admin.py
+2
-0
edxval/migrations/0008_auto_20171026_0359.py
+21
-0
edxval/models.py
+0
-41
edxval/tests/constants.py
+1
-36
edxval/tests/test_views.py
+0
-111
No files found.
edxval/admin.py
View file @
1ed30a30
...
...
@@ -81,6 +81,8 @@ class TranscriptPreferenceAdmin(admin.ModelAdmin):
class
ThirdPartyTranscriptCredentialsStateAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'org'
,
'provider'
,
'exists'
,
'created'
,
'modified'
)
model
=
ThirdPartyTranscriptCredentialsState
verbose_name
=
'Organization Transcript Credential State'
verbose_name_plural
=
'Organization Transcript Credentials State'
...
...
edxval/migrations/0008_auto_20171026_0359.py
0 → 100644
View file @
1ed30a30
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'edxval'
,
'0007_transcript_credentials_state'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'subtitle'
,
name
=
'video'
,
),
migrations
.
DeleteModel
(
name
=
'Subtitle'
,
),
]
edxval/models.py
View file @
1ed30a30
...
...
@@ -482,47 +482,6 @@ class VideoTranscript(TimeStampedModel):
return
u'{lang} Transcript for {video}'
.
format
(
lang
=
self
.
language_code
,
video
=
self
.
video_id
)
SUBTITLE_FORMATS
=
(
(
'srt'
,
'SubRip'
),
(
'sjson'
,
'SRT JSON'
)
)
class
Subtitle
(
models
.
Model
):
"""
Subtitle for video
Attributes:
video: the video that the subtitles are for
fmt: the format of the subttitles file
"""
created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
modified
=
models
.
DateTimeField
(
auto_now
=
True
)
video
=
models
.
ForeignKey
(
Video
,
related_name
=
"subtitles"
)
fmt
=
models
.
CharField
(
max_length
=
20
,
db_index
=
True
,
choices
=
SUBTITLE_FORMATS
)
language
=
models
.
CharField
(
max_length
=
8
,
db_index
=
True
)
content
=
models
.
TextField
(
default
=
''
)
def
__str__
(
self
):
return
'
%
s Subtitle for
%
s'
%
(
self
.
language
,
self
.
video
)
def
get_absolute_url
(
self
):
"""
Returns the full url link to the edx_video_id
"""
return
reverse
(
'subtitle-content'
,
args
=
[
self
.
video
.
edx_video_id
,
self
.
language
])
@property
def
content_type
(
self
):
"""
Sjson is returned as application/json, otherwise text/plain
"""
if
self
.
fmt
==
'sjson'
:
return
'application/json'
else
:
return
'text/plain'
class
Cielo24Turnaround
(
object
):
"""
Cielo24 turnarounds.
...
...
edxval/tests/constants.py
View file @
1ed30a30
...
...
@@ -66,7 +66,6 @@ VIDEO_DICT_NEGATIVE_DURATION = dict(
edx_video_id
=
"thisis12char-thisis7"
,
status
=
"test"
,
encoded_videos
=
[],
subtitles
=
[]
)
VIDEO_DICT_BEE_INVALID
=
dict
(
client_video_id
=
"Barking Bee"
,
...
...
@@ -80,7 +79,6 @@ VIDEO_DICT_INVALID_ID = dict(
edx_video_id
=
"sloppy/sloth!!"
,
status
=
"test"
,
encoded_videos
=
[],
subtitles
=
[]
)
ENCODED_VIDEO_DICT_NEGATIVE_FILESIZE
=
dict
(
url
=
"http://www.meowmix.com"
,
...
...
@@ -101,7 +99,6 @@ VIDEO_DICT_NON_LATIN_TITLE = dict(
edx_video_id
=
"ID"
,
status
=
"test"
,
encoded_videos
=
[],
subtitles
=
[]
)
VIDEO_DICT_NON_LATIN_ID
=
dict
(
client_video_id
=
"Hungry Hamster"
,
...
...
@@ -109,22 +106,9 @@ VIDEO_DICT_NON_LATIN_ID = dict(
edx_video_id
=
"밥줘"
,
status
=
"test"
,
encoded_videos
=
[],
subtitles
=
[]
)
PROFILE_INVALID_NAME
=
"lo/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
"""
...
...
@@ -199,7 +183,6 @@ 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_FISH_WITH_HLS
=
dict
(
...
...
@@ -208,7 +191,6 @@ COMPLETE_SET_FISH_WITH_HLS = dict(
ENCODED_VIDEO_DICT_FISH_DESKTOP
,
ENCODED_VIDEO_DICT_FISH_HLS
,
],
subtitles
=
[
SUBTITLE_DICT_SRT
,
SUBTITLE_DICT_SJSON
],
**
VIDEO_DICT_FISH
)
COMPLETE_SET_TWO_MOBILE_FISH
=
dict
(
...
...
@@ -216,7 +198,6 @@ 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
(
...
...
@@ -225,7 +206,6 @@ COMPLETE_SET_UPDATE_FISH = dict(
ENCODED_VIDEO_DICT_UPDATE_FISH_DESKTOP
,
ENCODED_VIDEO_DICT_UPDATE_FISH_HLS
,
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_FISH
)
COMPLETE_SET_DIFFERENT_ID_UPDATE_FISH
=
dict
(
...
...
@@ -233,7 +213,6 @@ COMPLETE_SET_DIFFERENT_ID_UPDATE_FISH = dict(
ENCODED_VIDEO_DICT_UPDATE_FISH_MOBILE
,
ENCODED_VIDEO_DICT_UPDATE_FISH_DESKTOP
],
subtitles
=
[
SUBTITLE_DICT_SRT
,
SUBTITLE_DICT_SJSON
],
**
VIDEO_DICT_DIFFERENT_ID_FISH
)
COMPLETE_SET_FIRST_HALF_UPDATE_FISH
=
dict
(
...
...
@@ -241,14 +220,12 @@ COMPLETE_SET_FIRST_HALF_UPDATE_FISH = dict(
ENCODED_VIDEO_DICT_UPDATE_FISH_MOBILE
,
ENCODED_VIDEO_DICT_FISH_DESKTOP
],
subtitles
=
[
SUBTITLE_DICT_SRT
,
SUBTITLE_DICT_SJSON
],
**
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
(
...
...
@@ -256,7 +233,6 @@ 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
(
...
...
@@ -268,7 +244,6 @@ COMPLETE_SET_INVALID_VIDEO_FISH = dict(
ENCODED_VIDEO_DICT_FISH_MOBILE
,
ENCODED_VIDEO_DICT_FISH_DESKTOP
],
subtitles
=
[
SUBTITLE_DICT_SRT
]
)
COMPLETE_SETS_ALL_INVALID
=
[
...
...
@@ -300,14 +275,12 @@ 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_WITH_COURSE_KEY
=
dict
(
...
...
@@ -315,7 +288,6 @@ COMPLETE_SET_WITH_COURSE_KEY = dict(
encoded_videos
=
[
ENCODED_VIDEO_DICT_STAR
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_WITH_SOME_INVALID_COURSE_KEY
=
dict
(
...
...
@@ -323,7 +295,6 @@ COMPLETE_SET_WITH_SOME_INVALID_COURSE_KEY = dict(
encoded_videos
=
[
ENCODED_VIDEO_DICT_STAR
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_WITH_OTHER_COURSE_KEYS
=
dict
(
...
...
@@ -331,7 +302,6 @@ COMPLETE_SET_WITH_OTHER_COURSE_KEYS = dict(
encoded_videos
=
[
ENCODED_VIDEO_DICT_STAR
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_NOT_A_LIST
=
dict
(
...
...
@@ -341,7 +311,6 @@ COMPLETE_SET_NOT_A_LIST = dict(
bitrate
=
42
,
profile
=
1
),
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
COMPLETE_SET_EXTRA_VIDEO_FIELD
=
dict
(
...
...
@@ -354,7 +323,6 @@ COMPLETE_SET_EXTRA_VIDEO_FIELD = dict(
video
=
"This should be overridden by parent video field"
)
],
subtitles
=
[
SUBTITLE_DICT_SRT
],
**
VIDEO_DICT_STAR
)
"""
...
...
@@ -378,7 +346,6 @@ VIDEO_DICT_ZEBRA = dict(
edx_video_id
=
"zestttt"
,
status
=
"test"
,
encoded_videos
=
[],
subtitles
=
[]
)
VIDEO_DICT_ANIMAL
=
dict
(
client_video_id
=
"Average Animal"
,
...
...
@@ -386,7 +353,6 @@ VIDEO_DICT_ANIMAL = dict(
edx_video_id
=
"mediocrity"
,
status
=
"test"
,
encoded_videos
=
[],
subtitles
=
[]
)
VIDEO_DICT_UPDATE_ANIMAL
=
dict
(
client_video_id
=
"Above Average Animal"
,
...
...
@@ -394,7 +360,6 @@ VIDEO_DICT_UPDATE_ANIMAL = dict(
edx_video_id
=
"mediocrity"
,
status
=
"test"
,
encoded_videos
=
[],
subtitles
=
[]
)
VIDEO_TRANSCRIPT_CIELO24
=
dict
(
...
...
edxval/tests/test_views.py
View file @
1ed30a30
...
...
@@ -209,33 +209,6 @@ class VideoDetail(APIAuthTestCase):
)
self
.
assertEqual
(
len
(
videos
[
0
]
.
encoded_videos
.
all
()),
1
)
@unittest.skip
(
"Skipping for now. We may need this later when we create transcripts alongwith video"
)
def
test_update_remove_subtitles
(
self
):
# Create some subtitles
self
.
_create_videos
(
constants
.
COMPLETE_SET_STAR
)
# Sanity check that the subtitles have been created
videos
=
Video
.
objects
.
all
()
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
len
(
videos
[
0
]
.
subtitles
.
all
()),
1
)
# Update with an empty list of subtitles
url
=
reverse
(
'video-detail'
,
kwargs
=
{
"edx_video_id"
:
constants
.
COMPLETE_SET_STAR
.
get
(
"edx_video_id"
)}
)
response
=
self
.
client
.
put
(
url
,
dict
(
subtitles
=
[],
encoded_videos
=
[],
**
constants
.
VIDEO_DICT_STAR
),
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
# Expect that subtitles have been removed
videos
=
Video
.
objects
.
all
()
self
.
assertEqual
(
len
(
videos
),
1
)
self
.
assertEqual
(
len
(
videos
[
0
]
.
subtitles
.
all
()),
0
)
def
test_update_remove_encoded_videos
(
self
):
# Create some encoded videos
self
.
_create_videos
(
constants
.
COMPLETE_SET_STAR
)
...
...
@@ -626,7 +599,6 @@ class VideoListTest(APIAuthTestCase):
'bitrate'
:
6767
,
}
],
'subtitles'
:
[],
'courses'
:
[
'youtube'
],
'client_video_id'
:
"Funny Cats"
,
'duration'
:
122
...
...
@@ -734,89 +706,6 @@ class VideoDetailTest(APIAuthTestCase):
self
.
client
.
get
(
"/edxval/videos/"
)
.
data
@unittest.skip
(
"Skipping for now. We may need these later when we create transcripts alongwith video"
)
class
SubtitleDetailTest
(
APIAuthTestCase
):
"""
Tests for subtitle API
"""
def
setUp
(
self
):
Profile
.
objects
.
create
(
profile_name
=
constants
.
PROFILE_MOBILE
)
Profile
.
objects
.
create
(
profile_name
=
constants
.
PROFILE_DESKTOP
)
super
(
SubtitleDetailTest
,
self
)
.
setUp
()
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/videos/"
)
.
data
self
.
assertEqual
(
len
(
video
),
1
)
self
.
assertEqual
(
len
(
video
[
0
]
.
get
(
"subtitles"
)),
2
)
video_subtitles
=
video
[
0
][
'subtitles'
][
0
]
response
=
self
.
client
.
get
(
video_subtitles
[
'content_url'
])
self
.
assertEqual
(
response
.
content
,
constants
.
SUBTITLE_DICT_SRT
[
'content'
])
self
.
assertEqual
(
response
[
'Content-Type'
],
'text/plain'
)
video_subtitles
=
video
[
0
][
'subtitles'
][
1
]
response
=
self
.
client
.
get
(
video_subtitles
[
'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
video_subtitles
=
video
[
'subtitles'
][
0
]
url
=
reverse
(
'subtitle-detail'
,
kwargs
=
{
'video__edx_video_id'
:
video
[
'edx_video_id'
],
'language'
:
video_subtitles
[
'language'
]})
video_subtitles
[
'content'
]
=
'testing 123'
response
=
self
.
client
.
put
(
url
,
video_subtitles
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
self
.
client
.
get
(
video_subtitles
[
'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
video_subtitles
=
video
[
'subtitles'
][
1
]
url
=
reverse
(
'subtitle-detail'
,
kwargs
=
{
'video__edx_video_id'
:
video
[
'edx_video_id'
],
'language'
:
video_subtitles
[
'language'
]})
video_subtitles
[
'content'
]
=
'testing 123'
response
=
self
.
client
.
put
(
url
,
video_subtitles
,
format
=
'json'
)
# not in json format
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
video_subtitles
[
'content'
]
=
"""{"start": "00:00:00"
}"""
response
=
self
.
client
.
put
(
url
,
video_subtitles
,
format
=
'json'
)
self
.
assertEqual
(
self
.
client
.
get
(
video_subtitles
[
'content_url'
])
.
content
,
'{"start": "00:00:00"}'
)
@ddt
class
VideoImagesViewTest
(
APIAuthTestCase
):
"""
...
...
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