Skip to content

Commit

Permalink
Add Error Description Field To Video Model (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
zainab-amir authored May 4, 2020
1 parent 966857c commit b8c8769
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
18 changes: 18 additions & 0 deletions edxval/migrations/0002_add_error_description_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.12 on 2020-04-29 05:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('edxval', '0001_squashed_0016_add_transcript_credentials_model'),
]

operations = [
migrations.AddField(
model_name='video',
name='error_description',
field=models.TextField(blank=True, null=True, verbose_name='Error Description'),
),
]
1 change: 1 addition & 0 deletions edxval/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Video(models.Model):
client_video_id = models.CharField(max_length=255, db_index=True, blank=True)
duration = models.FloatField(validators=[MinValueValidator(0)])
status = models.CharField(max_length=255, db_index=True)
error_description = models.TextField('Error Description', blank=True, null=True)

def get_absolute_url(self):
"""
Expand Down
31 changes: 31 additions & 0 deletions edxval/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,11 @@ def setUp(self):
'patch_data': {'edx_video_id': 'super-soaker', 'status': 'partial_failure'},
'message': None,
'status_code': status.HTTP_200_OK,
},
{
'patch_data': {'edx_video_id': 'super-soaker', 'status': 'transcript_failed'},
'message': None,
'status_code': status.HTTP_200_OK,
}
)
@unpack
Expand All @@ -965,6 +970,32 @@ def test_video_status(self, patch_data, message, status_code):
self.assertEqual(response.status_code, status_code)
self.assertEqual(response.data.get('message'), message)

def test_error_description(self):
"""
Test that if error description is present in request, it is updated for
the video instance.
"""
request_data = {
'edx_video_id': 'super-soaker', 'status': 'pipeline_error', 'error_description': 'test-error-desc'
}
response = self.client.patch(self.url, request_data, format='json')

self.video.refresh_from_db()
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(self.video.error_description, 'test-error-desc')

def test_no_error_description(self):
"""
Test that error description is an optional parameter for status update request.
"""
response = self.client.patch(
self.url, {'edx_video_id': 'super-soaker', 'status': 'pipeline_error'}, format='json'
)

self.video.refresh_from_db()
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIsNone(self.video.error_description)


@ddt
class HLSMissingVideoViewTest(APIAuthTestCase):
Expand Down
2 changes: 2 additions & 0 deletions edxval/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'partial_failure',
'pipeline_error',
'transcription_in_progress',
'transcript_failed',
'transcript_ready',
'transcode_active',
]
Expand Down Expand Up @@ -211,6 +212,7 @@ def patch(self, request):
try:
video = Video.objects.get(edx_video_id=edx_video_id)
video.status = video_status
video.error_description = request.data.get('error_description')
video.save()
response_status = status.HTTP_200_OK
response_payload = {}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def load_requirements(*requirements_paths):
return list(requirements)


VERSION = '1.3.3'
VERSION = '1.3.4'

if sys.argv[-1] == 'tag':
print("Tagging the version on github:")
Expand Down

0 comments on commit b8c8769

Please sign in to comment.