From 4ed93be5ff32ff21436c73e8973009597787a2eb Mon Sep 17 00:00:00 2001 From: Ayub khan Date: Tue, 9 Jul 2019 13:09:08 +0500 Subject: [PATCH] INCR-328 python3 compatibility --- .../contentstore/tests/test_contentstore.py | 8 +- .../contentstore/tests/test_course_listing.py | 7 +- .../tests/test_courseware_index.py | 81 ++++++++++--------- .../contentstore/tests/test_export_git.py | 2 + .../contentstore/tests/test_i18n.py | 2 + .../contentstore/tests/test_orphan.py | 17 ++-- .../contentstore/tests/test_permissions.py | 3 + .../tests/test_transcripts_utils.py | 2 + .../tests/test_users_default_role.py | 2 + .../contentstore/tests/test_video_utils.py | 34 ++++---- 10 files changed, 89 insertions(+), 69 deletions(-) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index e0df1a65ac..8211836d8f 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from __future__ import print_function +from __future__ import absolute_import, print_function import copy import shutil @@ -14,6 +14,7 @@ from uuid import uuid4 import ddt import lxml.html import mock +import six from django.conf import settings from django.contrib.auth.models import User from django.middleware.csrf import _compare_salted_tokens @@ -27,12 +28,13 @@ from opaque_keys.edx.keys import AssetKey, CourseKey, UsageKey from opaque_keys.edx.locations import CourseLocator from path import Path as path from six import text_type +from six.moves import range from waffle.testutils import override_switch +from contentstore.config import waffle from contentstore.tests.utils import AjaxEnabledTestClient, CourseTestCase, get_url, parse_json from contentstore.utils import delete_course, reverse_course_url, reverse_url from contentstore.views.component import ADVANCED_COMPONENT_TYPES -from contentstore.config import waffle from course_action_state.managers import CourseActionStateItemNotFoundError from course_action_state.models import CourseRerunState, CourseRerunUIStateManager from openedx.core.djangoapps.django_comment_common.utils import are_permissions_roles_seeded @@ -1930,7 +1932,7 @@ class RerunCourseTest(ContentStoreTestCase): 'course_key': destination_course_key, 'should_display': True, } - for field_name, expected_value in expected_states.iteritems(): + for field_name, expected_value in six.iteritems(expected_states): self.assertEquals(getattr(rerun_state, field_name), expected_value) # Verify that the creator is now enrolled in the course. diff --git a/cms/djangoapps/contentstore/tests/test_course_listing.py b/cms/djangoapps/contentstore/tests/test_course_listing.py index 8cc49506fa..99dd9e92fe 100644 --- a/cms/djangoapps/contentstore/tests/test_course_listing.py +++ b/cms/djangoapps/contentstore/tests/test_course_listing.py @@ -2,6 +2,8 @@ Unit tests for getting the list of courses for a user through iterating all courses and by reversing group name formats. """ +from __future__ import absolute_import + import random import ddt @@ -10,6 +12,7 @@ from django.conf import settings from django.test import RequestFactory from mock import Mock, patch from opaque_keys.edx.locations import CourseLocator +from six.moves import range from contentstore.tests.utils import AjaxEnabledTestClient from contentstore.utils import delete_course @@ -172,7 +175,7 @@ class TestCourseListing(ModuleStoreTestCase): with self.store.default_store(default_store): # Create few courses - for num in xrange(TOTAL_COURSES_COUNT): + for num in range(TOTAL_COURSES_COUNT): course_location = self.store.make_course_key('Org', 'CreatedCourse' + str(num), 'Run') self._create_course_with_access_groups(course_location, self.user, default_store) @@ -249,7 +252,7 @@ class TestCourseListing(ModuleStoreTestCase): reversing django groups """ # create list of random course numbers which will be accessible to the user - user_course_ids = random.sample(range(TOTAL_COURSES_COUNT), USER_COURSES_COUNT) + user_course_ids = random.sample(list(range(TOTAL_COURSES_COUNT)), USER_COURSES_COUNT) # create courses and assign those to the user which have their number in user_course_ids with self.store.default_store(store): diff --git a/cms/djangoapps/contentstore/tests/test_courseware_index.py b/cms/djangoapps/contentstore/tests/test_courseware_index.py index 880f160bc9..89f0357868 100644 --- a/cms/djangoapps/contentstore/tests/test_courseware_index.py +++ b/cms/djangoapps/contentstore/tests/test_courseware_index.py @@ -1,7 +1,8 @@ """ Testing indexing of the courseware as it is changed """ -from __future__ import print_function +from __future__ import absolute_import, print_function + import json import time from datetime import datetime @@ -10,11 +11,13 @@ from uuid import uuid4 import ddt import pytest +import six from django.conf import settings from lazy.lazy import lazy from mock import patch from pytz import UTC from search.search_engine_base import SearchEngine +from six.moves import range from contentstore.courseware_index import ( CourseAboutSearchIndexer, @@ -259,7 +262,7 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): ) def _get_default_search(self): - return {"course": unicode(self.course.id)} + return {"course": six.text_type(self.course.id)} def _test_indexing_course(self, store): """ indexing course tests """ @@ -383,10 +386,10 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): results = response["results"] date_map = { - unicode(self.chapter.location): early_date, - unicode(self.sequential.location): early_date, - unicode(self.vertical.location): later_date, - unicode(self.html_unit.location): later_date, + six.text_type(self.chapter.location): early_date, + six.text_type(self.sequential.location): early_date, + six.text_type(self.vertical.location): later_date, + six.text_type(self.html_unit.location): later_date, } for result in results: self.assertEqual(result["data"]["start_date"], date_map[result["data"]["id"]]) @@ -449,7 +452,7 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): self.reindex_course(store) response = self.searcher.search( doc_type=CourseAboutSearchIndexer.DISCOVERY_DOCUMENT_TYPE, - field_dictionary={"course": unicode(self.course.id)} + field_dictionary={"course": six.text_type(self.course.id)} ) self.assertEqual(response["total"], 1) self.assertEqual(response["results"][0]["data"]["content"]["display_name"], display_name) @@ -463,7 +466,7 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): self.reindex_course(store) response = self.searcher.search( doc_type=CourseAboutSearchIndexer.DISCOVERY_DOCUMENT_TYPE, - field_dictionary={"course": unicode(self.course.id)} + field_dictionary={"course": six.text_type(self.course.id)} ) self.assertEqual(response["total"], 1) self.assertEqual(response["results"][0]["data"]["content"]["short_description"], short_description) @@ -471,13 +474,13 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): def _test_course_about_mode_index(self, store): """ Test that informational properties in the course modes store end up in the course_info index """ honour_mode = CourseMode( - course_id=unicode(self.course.id), + course_id=six.text_type(self.course.id), mode_slug=CourseMode.HONOR, mode_display_name=CourseMode.HONOR ) honour_mode.save() verified_mode = CourseMode( - course_id=unicode(self.course.id), + course_id=six.text_type(self.course.id), mode_slug=CourseMode.VERIFIED, mode_display_name=CourseMode.VERIFIED, min_price=1 @@ -487,7 +490,7 @@ class TestCoursewareSearchIndexer(MixedWithOptionsTestCase): response = self.searcher.search( doc_type=CourseAboutSearchIndexer.DISCOVERY_DOCUMENT_TYPE, - field_dictionary={"course": unicode(self.course.id)} + field_dictionary={"course": six.text_type(self.course.id)} ) self.assertEqual(response["total"], 1) self.assertIn(CourseMode.HONOR, response["results"][0]["data"]["modes"]) @@ -638,13 +641,13 @@ class TestLargeCourseDeletions(MixedWithOptionsTestCase): """ Test that deleting items from a course works even when present within a very large course """ def id_list(top_parent_object): """ private function to get ids from object down the tree """ - list_of_ids = [unicode(top_parent_object.location)] + list_of_ids = [six.text_type(top_parent_object.location)] for child in top_parent_object.get_children(): list_of_ids.extend(id_list(child)) return list_of_ids course, course_size = create_large_course(store, load_factor) - self.course_id = unicode(course.id) + self.course_id = six.text_type(course.id) # index full course CoursewareSearchIndexer.do_course_reindex(store, course.id) @@ -753,7 +756,7 @@ class TestTaskExecution(SharedModuleStoreTestCase): searcher = SearchEngine.get_search_engine(CoursewareSearchIndexer.INDEX_NAME) response = searcher.search( doc_type=CoursewareSearchIndexer.DOCUMENT_TYPE, - field_dictionary={"course": unicode(self.course.id)} + field_dictionary={"course": six.text_type(self.course.id)} ) self.assertEqual(response["total"], 0) @@ -762,14 +765,14 @@ class TestTaskExecution(SharedModuleStoreTestCase): # Note that this test will only succeed if celery is working in inline mode response = searcher.search( doc_type=CoursewareSearchIndexer.DOCUMENT_TYPE, - field_dictionary={"course": unicode(self.course.id)} + field_dictionary={"course": six.text_type(self.course.id)} ) self.assertEqual(response["total"], 3) def test_task_library_update(self): """ Making sure that the receiver correctly fires off the task when invoked by signal """ searcher = SearchEngine.get_search_engine(LibrarySearchIndexer.INDEX_NAME) - library_search_key = unicode(normalize_key_for_search(self.library.location.library_key)) + library_search_key = six.text_type(normalize_key_for_search(self.library.location.library_key)) response = searcher.search(field_dictionary={"library": library_search_key}) self.assertEqual(response["total"], 0) @@ -821,7 +824,7 @@ class TestLibrarySearchIndexer(MixedWithOptionsTestCase): def _get_default_search(self): """ Returns field_dictionary for default search """ - return {"library": unicode(self.library.location.library_key.replace(version_guid=None, branch=None))} + return {"library": six.text_type(self.library.location.library_key.replace(version_guid=None, branch=None))} def reindex_library(self, store): """ kick off complete reindex of the course """ @@ -1177,9 +1180,9 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase): """ return { 'course_name': self.course.display_name, - 'id': unicode(html_unit.location), + 'id': six.text_type(html_unit.location), 'content': {'html_content': '', 'display_name': html_unit.display_name}, - 'course': unicode(self.course.id), + 'course': six.text_type(self.course.id), 'location': [ self.chapter.display_name, self.sequential.display_name, @@ -1197,9 +1200,9 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase): """ return { 'course_name': self.course.display_name, - 'id': unicode(html_unit.location), + 'id': six.text_type(html_unit.location), 'content': {'html_content': '', 'display_name': html_unit.display_name}, - 'course': unicode(self.course.id), + 'course': six.text_type(self.course.id), 'location': [ self.chapter.display_name, self.sequential2.display_name, @@ -1218,7 +1221,7 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase): return { 'start_date': datetime(2015, 4, 1, 0, 0, tzinfo=UTC), 'content': {'display_name': vertical.display_name}, - 'course': unicode(self.course.id), + 'course': six.text_type(self.course.id), 'location': [ self.chapter.display_name, self.sequential2.display_name, @@ -1226,7 +1229,7 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase): ], 'content_type': 'Sequence', 'content_groups': content_groups, - 'id': unicode(vertical.location), + 'id': six.text_type(vertical.location), 'course_name': self.course.display_name, 'org': self.course.org } @@ -1237,9 +1240,9 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase): """ return { 'course_name': self.course.display_name, - 'id': unicode(html_unit.location), + 'id': six.text_type(html_unit.location), 'content': {'html_content': '', 'display_name': html_unit.display_name}, - 'course': unicode(self.course.id), + 'course': six.text_type(self.course.id), 'location': [ self.chapter.display_name, self.sequential.display_name, @@ -1269,7 +1272,7 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase): # Only published modules should be in the index added_to_index = self.reindex_course(self.store) self.assertEqual(added_to_index, 16) - response = self.searcher.search(field_dictionary={"course": unicode(self.course.id)}) + response = self.searcher.search(field_dictionary={"course": six.text_type(self.course.id)}) self.assertEqual(response["total"], 17) group_access_content = {'group_access': {666: [1]}} @@ -1287,44 +1290,44 @@ class GroupConfigurationSearchMongo(CourseTestCase, MixedWithOptionsTestCase): self.assertTrue(mock_index.called) indexed_content = self._get_index_values_from_call_args(mock_index) self.assertIn(self._html_group_result(self.html_unit1, [1]), indexed_content) - self.assertIn(self._html_experiment_group_result(self.html_unit4, [unicode(2)]), indexed_content) - self.assertIn(self._html_experiment_group_result(self.html_unit5, [unicode(3)]), indexed_content) - self.assertIn(self._html_experiment_group_result(self.html_unit6, [unicode(4)]), indexed_content) - self.assertNotIn(self._html_experiment_group_result(self.html_unit6, [unicode(5)]), indexed_content) + self.assertIn(self._html_experiment_group_result(self.html_unit4, [six.text_type(2)]), indexed_content) + self.assertIn(self._html_experiment_group_result(self.html_unit5, [six.text_type(3)]), indexed_content) + self.assertIn(self._html_experiment_group_result(self.html_unit6, [six.text_type(4)]), indexed_content) + self.assertNotIn(self._html_experiment_group_result(self.html_unit6, [six.text_type(5)]), indexed_content) self.assertIn( - self._vertical_experiment_group_result(self.condition_0_vertical, [unicode(2)]), + self._vertical_experiment_group_result(self.condition_0_vertical, [six.text_type(2)]), indexed_content ) self.assertNotIn( - self._vertical_experiment_group_result(self.condition_1_vertical, [unicode(2)]), + self._vertical_experiment_group_result(self.condition_1_vertical, [six.text_type(2)]), indexed_content ) self.assertNotIn( - self._vertical_experiment_group_result(self.condition_2_vertical, [unicode(2)]), + self._vertical_experiment_group_result(self.condition_2_vertical, [six.text_type(2)]), indexed_content ) self.assertNotIn( - self._vertical_experiment_group_result(self.condition_0_vertical, [unicode(3)]), + self._vertical_experiment_group_result(self.condition_0_vertical, [six.text_type(3)]), indexed_content ) self.assertIn( - self._vertical_experiment_group_result(self.condition_1_vertical, [unicode(3)]), + self._vertical_experiment_group_result(self.condition_1_vertical, [six.text_type(3)]), indexed_content ) self.assertNotIn( - self._vertical_experiment_group_result(self.condition_2_vertical, [unicode(3)]), + self._vertical_experiment_group_result(self.condition_2_vertical, [six.text_type(3)]), indexed_content ) self.assertNotIn( - self._vertical_experiment_group_result(self.condition_0_vertical, [unicode(4)]), + self._vertical_experiment_group_result(self.condition_0_vertical, [six.text_type(4)]), indexed_content ) self.assertNotIn( - self._vertical_experiment_group_result(self.condition_1_vertical, [unicode(4)]), + self._vertical_experiment_group_result(self.condition_1_vertical, [six.text_type(4)]), indexed_content ) self.assertIn( - self._vertical_experiment_group_result(self.condition_2_vertical, [unicode(4)]), + self._vertical_experiment_group_result(self.condition_2_vertical, [six.text_type(4)]), indexed_content ) mock_index.reset_mock() diff --git a/cms/djangoapps/contentstore/tests/test_export_git.py b/cms/djangoapps/contentstore/tests/test_export_git.py index 29d9276c45..27ae16da16 100644 --- a/cms/djangoapps/contentstore/tests/test_export_git.py +++ b/cms/djangoapps/contentstore/tests/test_export_git.py @@ -2,6 +2,8 @@ Test the ability to export courses to xml from studio """ +from __future__ import absolute_import + import copy import os import shutil diff --git a/cms/djangoapps/contentstore/tests/test_i18n.py b/cms/djangoapps/contentstore/tests/test_i18n.py index 45034e3839..e083a33c37 100644 --- a/cms/djangoapps/contentstore/tests/test_i18n.py +++ b/cms/djangoapps/contentstore/tests/test_i18n.py @@ -2,6 +2,8 @@ """ Tests for validate Internationalization and Module i18n service. """ +from __future__ import absolute_import + import gettext from unittest import skip diff --git a/cms/djangoapps/contentstore/tests/test_orphan.py b/cms/djangoapps/contentstore/tests/test_orphan.py index f6919d8bdd..2e73911451 100644 --- a/cms/djangoapps/contentstore/tests/test_orphan.py +++ b/cms/djangoapps/contentstore/tests/test_orphan.py @@ -1,9 +1,12 @@ """ Test finding orphans via the view and django config """ +from __future__ import absolute_import + import json import ddt +import six from opaque_keys.edx.locator import BlockUsageLocator from contentstore.tests.utils import CourseTestCase @@ -94,11 +97,11 @@ class TestOrphan(TestOrphanBase): ) self.assertEqual(len(orphans), 3, u"Wrong # {}".format(orphans)) location = course.location.replace(category='chapter', name='OrphanChapter') - self.assertIn(unicode(location), orphans) + self.assertIn(six.text_type(location), orphans) location = course.location.replace(category='vertical', name='OrphanVert') - self.assertIn(unicode(location), orphans) + self.assertIn(six.text_type(location), orphans) location = course.location.replace(category='html', name='OrphanHtml') - self.assertIn(unicode(location), orphans) + self.assertIn(six.text_type(location), orphans) @ddt.data( (ModuleStoreEnum.Type.split, 9, 5), @@ -171,8 +174,8 @@ class TestOrphan(TestOrphanBase): # HTML component has `vertical1` as its parent. html_parent = self.store.get_parent_location(multi_parent_html.location) - self.assertNotEqual(unicode(html_parent), unicode(orphan_vertical.location)) - self.assertEqual(unicode(html_parent), unicode(vertical1.location)) + self.assertNotEqual(six.text_type(html_parent), six.text_type(orphan_vertical.location)) + self.assertEqual(six.text_type(html_parent), six.text_type(vertical1.location)) # Get path of the `multi_parent_html` & verify path_to_location returns a expected path path = path_to_location(self.store, multi_parent_html.location) @@ -224,7 +227,7 @@ class TestOrphan(TestOrphanBase): # Verify chapter1 is parent of vertical1. vertical1_parent = self.store.get_parent_location(vertical1.location) - self.assertEqual(unicode(vertical1_parent), unicode(chapter1.location)) + self.assertEqual(six.text_type(vertical1_parent), six.text_type(chapter1.location)) # Make `Vertical1` the parent of `HTML0`. So `HTML0` will have to parents (`Vertical0` & `Vertical1`) vertical1.children.append(html.location) @@ -233,7 +236,7 @@ class TestOrphan(TestOrphanBase): # Get parent location & verify its either of the two verticals. As both parents are non-orphan, # alphabetically least is returned html_parent = self.store.get_parent_location(html.location) - self.assertEquals(unicode(html_parent), unicode(vertical1.location)) + self.assertEquals(six.text_type(html_parent), six.text_type(vertical1.location)) # verify path_to_location returns a expected path path = path_to_location(self.store, html.location) diff --git a/cms/djangoapps/contentstore/tests/test_permissions.py b/cms/djangoapps/contentstore/tests/test_permissions.py index 1f43a20532..30f7a61242 100644 --- a/cms/djangoapps/contentstore/tests/test_permissions.py +++ b/cms/djangoapps/contentstore/tests/test_permissions.py @@ -1,9 +1,12 @@ """ Test CRUD for authorization. """ +from __future__ import absolute_import + import copy from django.contrib.auth.models import User +from six.moves import range from contentstore.tests.utils import AjaxEnabledTestClient from contentstore.utils import reverse_course_url, reverse_url diff --git a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py index c1323126be..bba9984e76 100644 --- a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py +++ b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- """ Tests for transcripts_utils. """ +from __future__ import absolute_import + import copy import json import tempfile diff --git a/cms/djangoapps/contentstore/tests/test_users_default_role.py b/cms/djangoapps/contentstore/tests/test_users_default_role.py index 32648657ca..bcadfde520 100644 --- a/cms/djangoapps/contentstore/tests/test_users_default_role.py +++ b/cms/djangoapps/contentstore/tests/test_users_default_role.py @@ -2,6 +2,8 @@ Unit tests for checking default forum role "Student" of a user when he creates a course or after deleting it creates same course again """ +from __future__ import absolute_import + from contentstore.tests.utils import AjaxEnabledTestClient from contentstore.utils import delete_course, reverse_url from courseware.tests.factories import UserFactory diff --git a/cms/djangoapps/contentstore/tests/test_video_utils.py b/cms/djangoapps/contentstore/tests/test_video_utils.py index 0783f0fd2f..76ef0e49aa 100644 --- a/cms/djangoapps/contentstore/tests/test_video_utils.py +++ b/cms/djangoapps/contentstore/tests/test_video_utils.py @@ -3,31 +3,29 @@ Unit tests for video utils. """ -from unittest import TestCase +from __future__ import absolute_import + from datetime import datetime +from unittest import TestCase + import ddt import pytz import requests +import six from django.conf import settings from django.core.files.uploadedfile import UploadedFile from django.test.utils import override_settings -from edxval.api import ( - create_profile, - create_video, - get_course_video_image_url, - update_video_image -) -from openedx.core.djangoapps.profile_images.tests.helpers import make_image_file - +from edxval.api import create_profile, create_video, get_course_video_image_url, update_video_image from mock import patch from contentstore.tests.utils import CourseTestCase from contentstore.video_utils import ( + YOUTUBE_THUMBNAIL_SIZES, download_youtube_video_thumbnail, scrape_youtube_thumbnail, - validate_video_image, - YOUTUBE_THUMBNAIL_SIZES + validate_video_image ) +from openedx.core.djangoapps.profile_images.tests.helpers import make_image_file class ValidateVideoImageTestCase(TestCase): @@ -63,7 +61,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase): def setUp(self): super(ScrapeVideoThumbnailsTestCase, self).setUp() - course_ids = [unicode(self.course.id)] + course_ids = [six.text_type(self.course.id)] profiles = ['youtube'] created = datetime.now(pytz.utc) previous_uploads = [ @@ -119,7 +117,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase): # Create video images. with make_image_file() as image_file: update_video_image( - 'test-youtube-video-2', unicode(self.course.id), image_file, 'image.jpg' + 'test-youtube-video-2', six.text_type(self.course.id), image_file, 'image.jpg' ) def mocked_youtube_thumbnail_response( @@ -235,7 +233,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase): """ Test that youtube thumbnails are correctly scrapped. """ - course_id = unicode(self.course.id) + course_id = six.text_type(self.course.id) video1_edx_video_id = 'test-youtube-video-1' video2_edx_video_id = 'test-youtube-video-2' @@ -289,7 +287,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase): """ Test that we get correct logs in case of failure as well as success. """ - course_id = unicode(self.course.id) + course_id = six.text_type(self.course.id) video1_edx_video_id = 'test-youtube-video-1' mocked_request.side_effect = [ self.mocked_youtube_thumbnail_response( @@ -324,14 +322,14 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase): 'dummy-content', None, u'This image file type is not supported. Supported file types are {supported_file_formats}.'.format( - supported_file_formats=settings.VIDEO_IMAGE_SUPPORTED_FILE_FORMATS.keys() + supported_file_formats=list(settings.VIDEO_IMAGE_SUPPORTED_FILE_FORMATS.keys()) ) ), ( None, None, u'This image file type is not supported. Supported file types are {supported_file_formats}.'.format( - supported_file_formats=settings.VIDEO_IMAGE_SUPPORTED_FILE_FORMATS.keys() + supported_file_formats=list(settings.VIDEO_IMAGE_SUPPORTED_FILE_FORMATS.keys()) ) ), ) @@ -350,7 +348,7 @@ class ScrapeVideoThumbnailsTestCase(CourseTestCase): Test that when no thumbnail is downloaded, video image is not updated. """ mock_download_youtube_thumbnail.return_value = image_content, image_content_type - course_id = unicode(self.course.id) + course_id = six.text_type(self.course.id) video1_edx_video_id = 'test-youtube-video-1' # Verify that video1 has no image attached.