diff --git a/cms/djangoapps/contentstore/config/waffle.py b/cms/djangoapps/contentstore/config/waffle.py index 6457e77b03..3fb8bb0979 100644 --- a/cms/djangoapps/contentstore/config/waffle.py +++ b/cms/djangoapps/contentstore/config/waffle.py @@ -2,6 +2,8 @@ This module contains various configuration settings via waffle switches for the contentstore app. """ +from __future__ import absolute_import + from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag, WaffleFlagNamespace, WaffleSwitchNamespace # Namespace diff --git a/cms/djangoapps/contentstore/config/waffle_utils.py b/cms/djangoapps/contentstore/config/waffle_utils.py index 86840acd7e..ac25116922 100644 --- a/cms/djangoapps/contentstore/config/waffle_utils.py +++ b/cms/djangoapps/contentstore/config/waffle_utils.py @@ -1,5 +1,7 @@ """Util methods for Waffle checks""" +from __future__ import absolute_import + from cms.djangoapps.contentstore.config.waffle import ENABLE_CHECKLISTS_QUALITY diff --git a/cms/djangoapps/contentstore/tests/test_clone_course.py b/cms/djangoapps/contentstore/tests/test_clone_course.py index 9ef484c91b..92cfded0ab 100644 --- a/cms/djangoapps/contentstore/tests/test_clone_course.py +++ b/cms/djangoapps/contentstore/tests/test_clone_course.py @@ -1,8 +1,11 @@ """ Unit tests for cloning a course between the same and different module stores. """ +from __future__ import absolute_import + import json +import six from django.conf import settings from mock import Mock, patch from opaque_keys.edx.locator import CourseLocator @@ -82,8 +85,8 @@ class CloneCourseTest(CourseTestCase): split_rerun_id = CourseLocator(org=org, course=course_number, run="2012_Q2") CourseRerunState.objects.initiated(course.id, split_rerun_id, self.user, fields['display_name']) result = rerun_course.delay( - unicode(course.id), - unicode(split_rerun_id), + six.text_type(course.id), + six.text_type(split_rerun_id), self.user.id, json.dumps(fields, cls=EdxJSONEncoder) ) @@ -106,7 +109,7 @@ class CloneCourseTest(CourseTestCase): # Mark the action as initiated fields = {'display_name': 'rerun'} CourseRerunState.objects.initiated(mongo_course1_id, split_course3_id, self.user, fields['display_name']) - result = rerun_course.delay(unicode(mongo_course1_id), unicode(split_course3_id), self.user.id, + result = rerun_course.delay(six.text_type(mongo_course1_id), six.text_type(split_course3_id), self.user.id, json.dumps(fields, cls=EdxJSONEncoder)) self.assertEqual(result.get(), "succeeded") self.assertTrue(has_course_author_access(self.user, split_course3_id), "Didn't grant access") @@ -114,7 +117,7 @@ class CloneCourseTest(CourseTestCase): self.assertEqual(rerun_state.state, CourseRerunUIStateManager.State.SUCCEEDED) # try creating rerunning again to same name and ensure it generates error - result = rerun_course.delay(unicode(mongo_course1_id), unicode(split_course3_id), self.user.id) + result = rerun_course.delay(six.text_type(mongo_course1_id), six.text_type(split_course3_id), self.user.id) self.assertEqual(result.get(), "duplicate course") # the below will raise an exception if the record doesn't exist CourseRerunState.objects.find_first( @@ -127,7 +130,7 @@ class CloneCourseTest(CourseTestCase): split_course4_id = CourseLocator(org="edx3", course="split3", run="rerun_fail") fields = {'display_name': 'total failure'} CourseRerunState.objects.initiated(split_course3_id, split_course4_id, self.user, fields['display_name']) - result = rerun_course.delay(unicode(split_course3_id), unicode(split_course4_id), self.user.id, + result = rerun_course.delay(six.text_type(split_course3_id), six.text_type(split_course4_id), self.user.id, json.dumps(fields, cls=EdxJSONEncoder)) self.assertIn("exception: ", result.get()) self.assertIsNone(self.store.get_course(split_course4_id), "Didn't delete course after error") diff --git a/cms/djangoapps/contentstore/tests/test_gating.py b/cms/djangoapps/contentstore/tests/test_gating.py index e61da3ace5..e39f78564b 100644 --- a/cms/djangoapps/contentstore/tests/test_gating.py +++ b/cms/djangoapps/contentstore/tests/test_gating.py @@ -1,6 +1,8 @@ """ Unit tests for the gating feature in Studio """ +from __future__ import absolute_import + from milestones.tests.utils import MilestonesTestCaseMixin from mock import patch diff --git a/cms/djangoapps/contentstore/tests/test_proctoring.py b/cms/djangoapps/contentstore/tests/test_proctoring.py index ff7428399a..e842259a50 100644 --- a/cms/djangoapps/contentstore/tests/test_proctoring.py +++ b/cms/djangoapps/contentstore/tests/test_proctoring.py @@ -2,15 +2,18 @@ Tests for the edx_proctoring integration into Studio """ +from __future__ import absolute_import + from datetime import datetime, timedelta import ddt +import six +from django.conf import settings from edx_proctoring.api import get_all_exams_for_course, get_review_policy_by_exam_id from mock import patch from pytz import UTC from contentstore.signals.handlers import listen_for_course_publish -from django.conf import settings from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory @@ -41,7 +44,7 @@ class TestProctoredExams(ModuleStoreTestCase): Helper method to compare the sequence with the stored exam, which should just be a single one """ - exams = get_all_exams_for_course(unicode(self.course.id)) + exams = get_all_exams_for_course(six.text_type(self.course.id)) self.assertEqual(len(exams), 1) @@ -56,8 +59,8 @@ class TestProctoredExams(ModuleStoreTestCase): # the hide after due value only applies to timed exams self.assertEqual(exam['hide_after_due'], sequence.hide_after_due) - self.assertEqual(exam['course_id'], unicode(self.course.id)) - self.assertEqual(exam['content_id'], unicode(sequence.location)) + self.assertEqual(exam['course_id'], six.text_type(self.course.id)) + self.assertEqual(exam['content_id'], six.text_type(sequence.location)) self.assertEqual(exam['exam_name'], sequence.display_name) self.assertEqual(exam['time_limit_mins'], sequence.default_time_limit_minutes) self.assertEqual(exam['is_proctored'], sequence.is_proctored_exam) @@ -164,7 +167,7 @@ class TestProctoredExams(ModuleStoreTestCase): listen_for_course_publish(self, self.course.id) - exams = get_all_exams_for_course(unicode(self.course.id)) + exams = get_all_exams_for_course(six.text_type(self.course.id)) self.assertEqual(len(exams), 1) sequence.is_time_limited = False @@ -195,7 +198,7 @@ class TestProctoredExams(ModuleStoreTestCase): listen_for_course_publish(self, self.course.id) - exams = get_all_exams_for_course(unicode(self.course.id)) + exams = get_all_exams_for_course(six.text_type(self.course.id)) self.assertEqual(len(exams), 1) self.store.delete_item(chapter.location, self.user.id) @@ -205,7 +208,7 @@ class TestProctoredExams(ModuleStoreTestCase): # look through exam table, the dangling exam # should be disabled - exams = get_all_exams_for_course(unicode(self.course.id)) + exams = get_all_exams_for_course(six.text_type(self.course.id)) self.assertEqual(len(exams), 1) exam = exams[0] @@ -230,7 +233,7 @@ class TestProctoredExams(ModuleStoreTestCase): listen_for_course_publish(self, self.course.id) - exams = get_all_exams_for_course(unicode(self.course.id)) + exams = get_all_exams_for_course(six.text_type(self.course.id)) self.assertEqual(len(exams), 0) @ddt.data( @@ -269,7 +272,7 @@ class TestProctoredExams(ModuleStoreTestCase): # there shouldn't be any exams because we haven't enabled that # advanced setting flag - exams = get_all_exams_for_course(unicode(self.course.id)) + exams = get_all_exams_for_course(six.text_type(self.course.id)) self.assertEqual(len(exams), expected_count) def test_self_paced_no_due_dates(self): @@ -297,7 +300,7 @@ class TestProctoredExams(ModuleStoreTestCase): is_onboarding_exam=False, ) listen_for_course_publish(self, self.course.id) - exams = get_all_exams_for_course(unicode(self.course.id)) + exams = get_all_exams_for_course(six.text_type(self.course.id)) # self-paced courses should ignore due dates assert exams[0]['due_date'] is None @@ -306,5 +309,5 @@ class TestProctoredExams(ModuleStoreTestCase): self.course.self_paced = False self.course = self.update_course(self.course, 1) listen_for_course_publish(self, self.course.id) - exams = get_all_exams_for_course(unicode(self.course.id)) + exams = get_all_exams_for_course(six.text_type(self.course.id)) assert exams[0]['due_date'] is not None diff --git a/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py b/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py index 6f882a79d1..68710b34eb 100644 --- a/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py +++ b/cms/djangoapps/contentstore/views/tests/test_credit_eligibility.py @@ -2,7 +2,10 @@ Unit tests for credit eligibility UI in Studio. """ +from __future__ import absolute_import + import mock +import six from contentstore.tests.utils import CourseTestCase from contentstore.utils import reverse_course_url @@ -20,7 +23,7 @@ class CreditEligibilityTest(CourseTestCase): def setUp(self): super(CreditEligibilityTest, self).setUp() self.course = CourseFactory.create(org='edX', number='dummy', display_name='Credit Course') - self.course_details_url = reverse_course_url('settings_handler', unicode(self.course.id)) + self.course_details_url = reverse_course_url('settings_handler', six.text_type(self.course.id)) @mock.patch.dict("django.conf.settings.FEATURES", {'ENABLE_CREDIT_ELIGIBILITY': False}) def test_course_details_with_disabled_setting(self): @@ -48,7 +51,7 @@ class CreditEligibilityTest(CourseTestCase): # verify that credit eligibility requirements block shows if the # course is set as credit course and it has eligibility requirements - credit_course = CreditCourse(course_key=unicode(self.course.id), enabled=True) + credit_course = CreditCourse(course_key=six.text_type(self.course.id), enabled=True) credit_course.save() self.assertEqual(len(get_credit_requirements(self.course.id)), 0) # test that after publishing course, minimum grade requirement is added diff --git a/cms/djangoapps/contentstore/views/tests/test_transcript_settings.py b/cms/djangoapps/contentstore/views/tests/test_transcript_settings.py index f2f7ef9f20..10b3bb1eb8 100644 --- a/cms/djangoapps/contentstore/views/tests/test_transcript_settings.py +++ b/cms/djangoapps/contentstore/views/tests/test_transcript_settings.py @@ -1,8 +1,11 @@ # -*- coding: utf-8 -*- +from __future__ import absolute_import + import json from io import BytesIO import ddt +import six from django.test.testcases import TestCase from django.urls import reverse from edxval import api @@ -241,7 +244,7 @@ class TranscriptDownloadTest(CourseTestCase): # Assert the actual response self.assertEqual(response.status_code, 200) self.assertEqual(response.content, expected_content) - for attribute, value in expected_headers.iteritems(): + for attribute, value in six.iteritems(expected_headers): self.assertEqual(response.get(attribute), value) @ddt.data( diff --git a/cms/djangoapps/contentstore/views/tests/utils.py b/cms/djangoapps/contentstore/views/tests/utils.py index 77cda406ea..52ebaad1e7 100644 --- a/cms/djangoapps/contentstore/views/tests/utils.py +++ b/cms/djangoapps/contentstore/views/tests/utils.py @@ -2,6 +2,8 @@ Utilities for view tests. """ +from __future__ import absolute_import + import json from contentstore.tests.utils import CourseTestCase