Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #85 from edx/yro/bugfix_0118
Browse files Browse the repository at this point in the history
Yro/EDUCATOR-2152
  • Loading branch information
yro authored Feb 9, 2018
2 parents d096135 + 6a2fc83 commit e4a89c4
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 161 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Mushtaq Ali <[email protected]>
Muhammad Ammar <[email protected]>
Gregory Martin <[email protected]>
101 changes: 73 additions & 28 deletions control/tests/test_heal.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,63 +107,113 @@ def test_heal(self):

@data(
{
'edx_id': '1',
'video_trans_status': 'Corrupt File',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
'expected_encodes': set(['hls', 'mobile_low'])
},
{
'edx_id': '1',
'video_trans_status': 'Review Reject',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
'expected_encodes': []
},
{
'edx_id': '1',
'video_trans_status': 'Review Hold',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
'expected_encodes': []
},
{
'edx_id': '2',
'video_trans_status': 'Complete',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': False,
'expected_encodes': set(['hls', 'mobile_low'])
},
{
'edx_id': '2',
'video_trans_status': 'Ingest',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
'expected_encodes': set(['hls', 'mobile_low'])
},
)
@unpack
def test_determine_fault(self, video_trans_status, video_trans_start, video_active, expected_encodes):
"""
Tests that determine_fault works in various video states.
"""
video_instance = Video(
edx_id='test_id',
video_trans_status=video_trans_status,
video_trans_start=video_trans_start,
video_active=video_active,
inst_class=self.course_object
)
video_instance.save()

encodes = self.heal_instance.determine_fault(video_instance)
self.assertEqual(encodes, expected_encodes)

@data(
{
'video_trans_status': 'Corrupt File',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
'expected_encodes': []
},
{
'video_trans_status': 'Review Reject',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
'expected_encodes': []
},
{
'video_trans_status': 'Review Hold',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
'expected_encodes': []
},
{
'video_trans_status': 'Complete',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': False,
'expected_encodes': set(['hls', 'mobile_low'])
},
{
'video_trans_status': 'Ingest',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
'expected_encodes': set(['hls', 'mobile_low'])
},
{
'edx_id': '1',
'video_trans_status': 'Corrupt File',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
'expected_encodes': []
},
)
@unpack
def test_determine_fault(self, edx_id, video_trans_status, video_trans_start, video_active):
"""
Tests that determine_fault works in various video states.
"""
def test_determine_fault_freeze_bug(
self, video_trans_status, video_trans_start, video_active, expected_encodes
):
video_instance = Video(
edx_id=edx_id,
edx_id='test_id',
video_trans_status=video_trans_status,
video_trans_start=video_trans_start,
video_active=video_active,
inst_class=self.course_object
)
video_instance.save()

encode_list = self.heal_instance.determine_fault(video_instance)
heal_instance_two = VedaHeal(freezing_bug=True)
encode_list = heal_instance_two.determine_fault(video_instance)
self.assertEqual(encode_list, expected_encodes)

if video_instance.edx_id == '1':
self.assertEqual(encode_list, [])
elif video_instance.edx_id == '2':
for e in encode_list:
self.assertTrue(e in self.encode_list)

@data(
{
Expand Down Expand Up @@ -271,8 +321,8 @@ def test_differentiate_encodes_val_status(self, uncompleted_encodes,
{
'uncompleted_encodes': ['test_encode', 'test_encode'],
'expected_encodes': ['test_encode', 'test_encode'],
'expected_long_corrupt': False,
'video_object': {
'edx_id': '1',
'video_trans_status': 'Complete',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
Expand All @@ -281,8 +331,8 @@ def test_differentiate_encodes_val_status(self, uncompleted_encodes,
{
'uncompleted_encodes': ['test_encode', 'test_encode', 'hls'],
'expected_encodes': ['test_encode', 'test_encode', 'hls'],
'expected_long_corrupt': False,
'video_object': {
'edx_id': '2',
'video_trans_status': 'Complete',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
Expand All @@ -291,18 +341,18 @@ def test_differentiate_encodes_val_status(self, uncompleted_encodes,
{
'uncompleted_encodes': ['test_encode', 'test_encode', 'hls'],
'expected_encodes': ['test_encode', 'test_encode', 'hls'],
'expected_long_corrupt': True,
'video_object': {
'edx_id': '3',
'video_trans_status': 'Ingest',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc) - timedelta(days=10),
'video_active': True,
}
}
)
@unpack
def test_determine_longterm_corrupt(self, uncompleted_encodes, expected_encodes, video_object):
def test_determine_longterm_corrupt(self, uncompleted_encodes, expected_encodes, video_object, expected_long_corrupt):
video_instance = Video(
edx_id=video_object['edx_id'],
edx_id='test_id',
video_trans_status=video_object['video_trans_status'],
video_trans_start=video_object['video_trans_start'],
video_active=video_object['video_active'],
Expand All @@ -317,9 +367,4 @@ def test_determine_longterm_corrupt(self, uncompleted_encodes, expected_encodes,
video_instance
)

if video_instance.edx_id == '1':
self.assertEqual(longterm_corrupt, False)
elif video_instance.edx_id == '2':
self.assertEqual(longterm_corrupt, False)
elif video_instance.edx_id == '3':
self.assertEqual(longterm_corrupt, True)
self.assertEqual(longterm_corrupt, expected_long_corrupt)
Loading

0 comments on commit e4a89c4

Please sign in to comment.