Merge pull request #20977 from edx/INCR-326
INCR-326 python3 compatibility
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
from opaque_keys.edx.django.models import CourseKeyField
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
""" receivers of course_published and library_updated events in order to trigger indexing task """
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from functools import wraps
|
||||
import logging
|
||||
|
||||
import six
|
||||
from django.core.cache import cache
|
||||
from django.dispatch import receiver
|
||||
from pytz import UTC
|
||||
@@ -62,7 +65,7 @@ def listen_for_course_publish(sender, course_key, **kwargs): # pylint: disable=
|
||||
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
||||
from contentstore.tasks import update_search_index
|
||||
|
||||
update_search_index.delay(unicode(course_key), datetime.now(UTC).isoformat())
|
||||
update_search_index.delay(six.text_type(course_key), datetime.now(UTC).isoformat())
|
||||
|
||||
|
||||
@receiver(SignalHandler.library_updated)
|
||||
@@ -75,7 +78,7 @@ def listen_for_library_update(sender, library_key, **kwargs): # pylint: disable
|
||||
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
||||
from contentstore.tasks import update_library_index
|
||||
|
||||
update_library_index.delay(unicode(library_key), datetime.now(UTC).isoformat())
|
||||
update_library_index.delay(six.text_type(library_key), datetime.now(UTC).isoformat())
|
||||
|
||||
|
||||
@receiver(SignalHandler.item_deleted)
|
||||
@@ -113,10 +116,10 @@ def handle_grading_policy_changed(sender, **kwargs):
|
||||
Receives signal and kicks off celery task to recalculate grades
|
||||
"""
|
||||
kwargs = {
|
||||
'course_key': unicode(kwargs.get('course_key')),
|
||||
'grading_policy_hash': unicode(kwargs.get('grading_policy_hash')),
|
||||
'event_transaction_id': unicode(get_event_transaction_id()),
|
||||
'event_transaction_type': unicode(get_event_transaction_type()),
|
||||
'course_key': six.text_type(kwargs.get('course_key')),
|
||||
'grading_policy_hash': six.text_type(kwargs.get('grading_policy_hash')),
|
||||
'event_transaction_id': six.text_type(get_event_transaction_id()),
|
||||
'event_transaction_type': six.text_type(get_event_transaction_type()),
|
||||
}
|
||||
result = task_compute_all_grades_for_course.apply_async(kwargs=kwargs, countdown=GRADING_POLICY_COUNTDOWN_SECONDS)
|
||||
log.info(u"Grades: Created {task_name}[{task_id}] with arguments {kwargs}".format(
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"""
|
||||
Contentstore signals
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.dispatch import Signal
|
||||
|
||||
# Signal that indicates that a course grading policy has been updated.
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
"""
|
||||
Test view handler for rerun (and eventually create)
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import datetime
|
||||
|
||||
import ddt
|
||||
from django.urls import reverse
|
||||
import six
|
||||
from django.test.client import RequestFactory
|
||||
from django.urls import reverse
|
||||
from mock import patch
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
@@ -68,7 +71,7 @@ class TestCourseListing(ModuleStoreTestCase):
|
||||
Just testing the functionality the view handler adds over the tasks tested in test_clone_course
|
||||
"""
|
||||
response = self.client.ajax_post(self.course_create_rerun_url, {
|
||||
'source_course_key': unicode(self.source_course_key),
|
||||
'source_course_key': six.text_type(self.source_course_key),
|
||||
'org': self.source_course_key.org, 'course': self.source_course_key.course, 'run': 'copy',
|
||||
'display_name': 'not the same old name',
|
||||
})
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
"""
|
||||
Tests for import_course_from_xml using the mongo modulestore.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import copy
|
||||
from uuid import uuid4
|
||||
|
||||
import ddt
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.test.client import Client
|
||||
from django.test.utils import override_settings
|
||||
@@ -268,7 +269,7 @@ class ContentStoreImportTest(ModuleStoreTestCase):
|
||||
self.assertIsNotNone(split_test_module)
|
||||
|
||||
remapped_verticals = {
|
||||
key: target_id.make_usage_key('vertical', value) for key, value in groups_to_verticals.iteritems()
|
||||
key: target_id.make_usage_key('vertical', value) for key, value in six.iteritems(groups_to_verticals)
|
||||
}
|
||||
|
||||
self.assertEqual(remapped_verticals, split_test_module.group_id_to_child)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"""Tests for CMS's requests to logs"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import mock
|
||||
from django.urls import reverse
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from six import unichr # pylint: disable=W0622
|
||||
|
||||
from contentstore.views.helpers import event as cms_user_track
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
'''
|
||||
Utilities for contentstore tests
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
import json
|
||||
import textwrap
|
||||
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.test.client import Client
|
||||
@@ -48,7 +51,7 @@ class AjaxEnabledTestClient(Client):
|
||||
Convenience method for client post which serializes the data into json and sets the accept type
|
||||
to json
|
||||
"""
|
||||
if not isinstance(data, basestring):
|
||||
if not isinstance(data, six.string_types):
|
||||
data = json.dumps(data or {})
|
||||
kwargs.setdefault("HTTP_X_REQUESTED_WITH", "XMLHttpRequest")
|
||||
kwargs.setdefault("HTTP_ACCEPT", "application/json")
|
||||
@@ -354,7 +357,7 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase):
|
||||
course1_asset_attrs = content_store.get_attrs(course1_id.make_asset_key(category, filename))
|
||||
course2_asset_attrs = content_store.get_attrs(course2_id.make_asset_key(category, filename))
|
||||
self.assertEqual(len(course1_asset_attrs), len(course2_asset_attrs))
|
||||
for key, value in course1_asset_attrs.iteritems():
|
||||
for key, value in six.iteritems(course1_asset_attrs):
|
||||
if key in ['_id', 'filename', 'uploadDate', 'content_son', 'thumbnail_location']:
|
||||
pass
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user