From 9f820c9e718961afa418befd3ba6c8566adea8ec Mon Sep 17 00:00:00 2001 From: Qubad786 Date: Wed, 6 Jun 2018 17:23:32 +0500 Subject: [PATCH] Fix tests --- .../tests/test_migrate_transcripts.py | 36 ++++++++++--------- cms/djangoapps/contentstore/tasks.py | 11 ++---- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py index 01fc5f359f..f173ad3da5 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py @@ -217,29 +217,30 @@ class TestMigrateTranscripts(ModuleStoreTestCase): """ Test migrate transcripts logging and output """ + course_id = unicode(self.course.id) expected_log = ( (LOGGER_NAME, 'INFO', - u'[Transcript migration] process for course {} started. Migrating 1 videos'.format( - unicode(self.course.id) + u'[Transcript Migration] process for course {} started. Migrating transcripts from 1 videos.'.format( + course_id )), (LOGGER_NAME, 'INFO', - '[Transcript migration] Migrating 2 transcripts'), + u'[Transcript Migration] Migrating 2 transcripts for course {}.'.format(course_id)), (LOGGER_NAME, 'INFO', - '[Transcript migration] Result: Language hr transcript of video test_edx_video_id will be migrated'), + u'[Transcript Migration] Result: Language hr transcript of video test_edx_video_id will be migrated'), (LOGGER_NAME, 'INFO', - '[Transcript migration] Result: Language ge transcript of video test_edx_video_id will be migrated'), + u'[Transcript Migration] Result: Language ge transcript of video test_edx_video_id will be migrated'), (LOGGER_NAME, 'INFO', - u'[Transcript migration] task submission for course {} ended.'.format( - unicode(self.course.id) + u'[Transcript Migration] task submission for course {} ended.'.format( + course_id )), (LOGGER_NAME, 'INFO', - "[Transcript migration] Result: None") + "[Transcript Migration] Result: None") ) with LogCapture(LOGGER_NAME, level=logging.INFO) as logger: @@ -252,33 +253,34 @@ class TestMigrateTranscripts(ModuleStoreTestCase): """ Test migrate transcripts exception logging """ + course_id = unicode(self.course_2.id) expected_log = ( (LOGGER_NAME, 'INFO', - u'[Transcript migration] process for course {} started. Migrating 1 videos'.format( - unicode(self.course_2.id) + u'[Transcript Migration] process for course {} started. Migrating transcripts from 1 videos.'.format( + course_id )), (LOGGER_NAME, 'INFO', - '[Transcript migration] Migrating 1 transcripts'), + u'[Transcript Migration] Migrating 1 transcripts for course {}.'.format(course_id)), (LOGGER_NAME, 'INFO', - u'[Transcript migration] process for ge transcript started'), + u'[Transcript migration] migration process is started for video [test_edx_video_id_2] language [ge].'), (LOGGER_NAME, 'ERROR', - "[Transcript migration] Exception: u'No transcript for `ge` language'"), + u"[Transcript migration] transcript migration failed for video [test_edx_video_id_2] and language [ge]."), (LOGGER_NAME, 'INFO', - "[Transcript migration] Result: Failed: language ge of video test_edx_video_id_2 with exception " + "[Transcript Migration] Result: Failed: language ge of video test_edx_video_id_2 with exception " "No transcript for `ge` language"), (LOGGER_NAME, 'INFO', - u'[Transcript migration] task submission for course {} ended.'.format( - unicode(self.course_2.id) + u'[Transcript Migration] task submission for course {} ended.'.format( + course_id )), (LOGGER_NAME, 'INFO', - "[Transcript migration] Result: None") + "[Transcript Migration] Result: None") ) with LogCapture(LOGGER_NAME, level=logging.INFO) as logger: diff --git a/cms/djangoapps/contentstore/tasks.py b/cms/djangoapps/contentstore/tasks.py index 261b3833c2..c4dabafab8 100644 --- a/cms/djangoapps/contentstore/tasks.py +++ b/cms/djangoapps/contentstore/tasks.py @@ -183,7 +183,7 @@ def async_migrate_transcript(self, course_key, **kwargs): # pylint: disable=un chord(sub_tasks)(callback) LOGGER.info( - "[%s] transcripts migration process for course %s ended.", + "[%s] task submission for course %s ended.", MIGRATION_LOGS_PREFIX, course_key ) @@ -240,8 +240,6 @@ def async_migrate_transcript_subtask(self, *args, **kwargs): # pylint: disable= ) # Start transcript's migration - message = None - # Clean `edx_video_id` edx_video_id = clean_video_id(video.edx_video_id) LOGGER.info( @@ -289,14 +287,9 @@ def async_migrate_transcript_subtask(self, *args, **kwargs): # pylint: disable= else: message = ( 'Success: transcript (language: {language_code}, edx_video_id: {edx_video_id}) has been migrated ' - 'for video [location].' + 'for video [{location}].' ).format(edx_video_id=edx_video_id, language_code=language_code, location=unicode(video.location)) - # Log to indicate that Migration has been ended. - LOGGER.info( - "[Transcript migration] migration process is ended for video [%s] language [%s].", - edx_video_id, language_code - ) return message