Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-video-pipeline
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-video-pipeline
Commits
05c4822d
Unverified
Commit
05c4822d
authored
Apr 04, 2018
by
Muhammad Ammar
Committed by
GitHub
Apr 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #98 from edx/fix-status-update
fix status update
parents
dfc600de
407f3442
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
2 deletions
+67
-2
control/tests/test_val.py
+43
-0
control/veda_val.py
+24
-2
No files found.
control/tests/test_val.py
View file @
05c4822d
...
...
@@ -3,6 +3,7 @@ import ast
import
os
import
sys
from
django.test
import
TestCase
from
ddt
import
data
,
ddt
,
unpack
from
mock
import
PropertyMock
,
patch
...
...
@@ -12,6 +13,7 @@ import responses
from
control.veda_val
import
VALAPICall
from
VEDA
import
utils
from
control.veda_file_ingest
import
VideoProto
from
VEDA_OS01.utils
import
ValTranscriptStatus
requests
.
packages
.
urllib3
.
disable_warnings
()
...
...
@@ -25,6 +27,7 @@ sys.path.append(os.path.dirname(os.path.dirname(__file__)))
CONFIG_DATA
=
utils
.
get_config
(
'test_config.yaml'
)
@ddt
class
TestVALAPI
(
TestCase
):
def
setUp
(
self
):
...
...
@@ -73,3 +76,43 @@ class TestVALAPI(TestCase):
self
.
assertFalse
(
response
.
status_code
==
404
)
self
.
assertFalse
(
response
.
status_code
>
299
)
@data
(
{
'encode_list'
:
[],
'val_status'
:
'file_complete'
,
'expected_response'
:
False
},
{
'encode_list'
:
[],
'val_status'
:
ValTranscriptStatus
.
TRANSCRIPT_READY
,
'expected_response'
:
False
},
{
'encode_list'
:
[],
'val_status'
:
ValTranscriptStatus
.
TRANSCRIPTION_IN_PROGRESS
,
'expected_response'
:
False
},
{
'encode_list'
:
[
'abc.mp4'
],
'val_status'
:
'file_complete'
,
'expected_response'
:
True
},
{
'encode_list'
:
[
'abc.mp4'
],
'val_status'
:
ValTranscriptStatus
.
TRANSCRIPT_READY
,
'expected_response'
:
True
},
{
'encode_list'
:
[
'abc.mp4'
],
'val_status'
:
ValTranscriptStatus
.
TRANSCRIPTION_IN_PROGRESS
,
'expected_response'
:
True
},
)
@unpack
def
test_val_should_update_status
(
self
,
encode_list
,
val_status
,
expected_response
):
"""
Verify that `should_update_status` works as expected.
"""
response
=
self
.
VAC
.
should_update_status
(
encode_list
,
val_status
)
self
.
assertEqual
(
response
,
expected_response
)
control/veda_val.py
View file @
05c4822d
...
...
@@ -11,6 +11,8 @@ import json
from
control_env
import
*
from
control.veda_utils
import
Output
,
VideoProto
from
VEDA_OS01.utils
import
ValTranscriptStatus
LOGGER
=
logging
.
getLogger
(
__name__
)
requests
.
packages
.
urllib3
.
disable_warnings
()
...
...
@@ -29,6 +31,12 @@ requests.packages.urllib3.disable_warnings()
'''
FILE_COMPLETE_STATUSES
=
(
'file_complete'
,
ValTranscriptStatus
.
TRANSCRIPT_READY
,
ValTranscriptStatus
.
TRANSCRIPTION_IN_PROGRESS
,
)
class
VALAPICall
(
object
):
...
...
@@ -290,6 +298,20 @@ class VALAPICall(object):
return
@staticmethod
def
should_update_status
(
encode_list
,
val_status
):
"""
Check if we need to update video status in val
Arguments:
encode_list (list): list of video encodes
val_status (unicode): val status
"""
if
len
(
encode_list
)
==
0
and
val_status
in
FILE_COMPLETE_STATUSES
:
return
False
return
True
def
send_404
(
self
):
"""
Generate new VAL ID
...
...
@@ -298,7 +320,7 @@ class VALAPICall(object):
self
.
val_data
[
'status'
]
=
self
.
val_status
if
len
(
self
.
encode_data
)
==
0
and
self
.
val_status
is
'file_complete'
:
if
self
.
should_update_status
(
self
.
encode_data
,
self
.
val_status
)
is
False
:
return
None
sending_data
=
dict
(
...
...
@@ -341,7 +363,7 @@ class VALAPICall(object):
"""
Make Request, finally
"""
if
len
(
self
.
encode_data
)
==
0
and
self
.
val_status
is
'file_complete'
:
if
self
.
should_update_status
(
self
.
encode_data
,
self
.
val_status
)
is
False
:
return
None
r4
=
requests
.
put
(
...
...
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