diff --git a/edxval/migrations/0002_add_error_description_field.py b/edxval/migrations/0002_add_error_description_field.py new file mode 100644 index 00000000..97c250b4 --- /dev/null +++ b/edxval/migrations/0002_add_error_description_field.py @@ -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'), + ), + ] diff --git a/edxval/models.py b/edxval/models.py index 7e2e06bf..b2e2a826 100644 --- a/edxval/models.py +++ b/edxval/models.py @@ -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): """ diff --git a/edxval/tests/test_views.py b/edxval/tests/test_views.py index 8863d68c..aee48f7d 100644 --- a/edxval/tests/test_views.py +++ b/edxval/tests/test_views.py @@ -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 @@ -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): diff --git a/edxval/views.py b/edxval/views.py index cb744356..d13b2021 100644 --- a/edxval/views.py +++ b/edxval/views.py @@ -38,6 +38,7 @@ 'partial_failure', 'pipeline_error', 'transcription_in_progress', + 'transcript_failed', 'transcript_ready', 'transcode_active', ] @@ -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 = {} diff --git a/setup.py b/setup.py index 39e84842..d8d46af3 100644 --- a/setup.py +++ b/setup.py @@ -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:")