From 9610aab0f8546fc2a9a569671f79683814d77a56 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 7 Oct 2019 17:12:04 -0400 Subject: [PATCH] Fix more cms contentstore tests. --- .../contentstore/management/commands/export_olx.py | 2 +- cms/djangoapps/contentstore/tests/test_i18n.py | 3 +++ cms/djangoapps/contentstore/tests/test_video_utils.py | 2 +- cms/djangoapps/contentstore/tests/tests.py | 5 +++-- common/lib/xmodule/xmodule/video_module/transcripts_utils.py | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/export_olx.py b/cms/djangoapps/contentstore/management/commands/export_olx.py index b1324b827c..1f4336fb88 100644 --- a/cms/djangoapps/contentstore/management/commands/export_olx.py +++ b/cms/djangoapps/contentstore/management/commands/export_olx.py @@ -67,7 +67,7 @@ class Command(BaseCommand): def _get_results(self, filename): """Load results from file""" - with open(filename, 'rb') as f: + with open(filename, 'rb') as f: # pylint: disable=open-builtin results = f.read() os.remove(filename) return results diff --git a/cms/djangoapps/contentstore/tests/test_i18n.py b/cms/djangoapps/contentstore/tests/test_i18n.py index fa02e2abcb..7a45186b8a 100644 --- a/cms/djangoapps/contentstore/tests/test_i18n.py +++ b/cms/djangoapps/contentstore/tests/test_i18n.py @@ -32,6 +32,8 @@ class FakeTranslations(ModuleI18nService): """ return self.translations.get(msgid, msgid) + gettext = ugettext + @staticmethod def translator(locales_map): # pylint: disable=method-hidden """Build mock translator for the given locales. @@ -123,6 +125,7 @@ class TestModuleI18nService(ModuleStoreTestCase): self.assertEqual(i18n_service.ugettext(self.test_language), 'dummy language') @mock.patch('django.utils.translation.ugettext', mock.Mock(return_value='XYZ-TEST-LANGUAGE')) + @mock.patch('django.utils.translation.gettext', mock.Mock(return_value='XYZ-TEST-LANGUAGE')) def test_django_translator_in_use_with_empty_block(self): """ Test: Django default translator should in use if we have an empty block diff --git a/cms/djangoapps/contentstore/tests/test_video_utils.py b/cms/djangoapps/contentstore/tests/test_video_utils.py index 76ef0e49aa..8747bc9cef 100644 --- a/cms/djangoapps/contentstore/tests/test_video_utils.py +++ b/cms/djangoapps/contentstore/tests/test_video_utils.py @@ -319,7 +319,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase): ) ), ( - 'dummy-content', + b'dummy-content', None, u'This image file type is not supported. Supported file types are {supported_file_formats}.'.format( supported_file_formats=list(settings.VIDEO_IMAGE_SUPPORTED_FILE_FORMATS.keys()) diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index d8a9f1b410..0b1a9f25f4 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -335,8 +335,9 @@ class AuthTestCase(ContentStoreTestCase): is turned off """ response = self.client.get(reverse('login')) - self.assertNotIn('Don't have a Studio Account? Sign up!', - response.content) + self.assertNotContains(response, + 'Don't have a Studio Account? Sign up!' + ) class ForumTestCase(CourseTestCase): diff --git a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py index aa1b34c101..87b11c953b 100644 --- a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py +++ b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py @@ -346,7 +346,7 @@ def copy_or_rename_transcript(new_name, old_name, item, delete_old=False, user=N """ filename = u'subs_{0}.srt.sjson'.format(old_name) content_location = StaticContent.compute_location(item.location.course_key, filename) - transcripts = contentstore().find(content_location).data + transcripts = contentstore().find(content_location).data.decode('utf-8') save_subs_to_store(json.loads(transcripts), new_name, item) item.sub = new_name item.save_with_metadata(user)