From 4041fd69aeb67f65421bcd6cf6d913803dd7514d Mon Sep 17 00:00:00 2001 From: Stuart Young Date: Wed, 15 May 2019 10:00:38 -0400 Subject: [PATCH] run python modernize --- lms/djangoapps/grades/rest_api/v1/gradebook_views.py | 6 ++++-- lms/djangoapps/grades/rest_api/v1/tests/mixins.py | 4 +++- .../grades/rest_api/v1/tests/test_gradebook_views.py | 1 + .../grades/rest_api/v1/tests/test_grading_policy_view.py | 6 ++++-- lms/djangoapps/grades/rest_api/v1/tests/test_views.py | 1 + lms/djangoapps/grades/rest_api/v1/urls.py | 1 + lms/djangoapps/grades/rest_api/v1/utils.py | 1 + lms/djangoapps/grades/rest_api/v1/views.py | 1 + 8 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lms/djangoapps/grades/rest_api/v1/gradebook_views.py b/lms/djangoapps/grades/rest_api/v1/gradebook_views.py index 98226b4731..e49dc0f145 100644 --- a/lms/djangoapps/grades/rest_api/v1/gradebook_views.py +++ b/lms/djangoapps/grades/rest_api/v1/gradebook_views.py @@ -1,6 +1,7 @@ """ Defines an endpoint for gradebook data related to a course. """ +from __future__ import absolute_import import logging from collections import namedtuple from contextlib import contextmanager @@ -67,6 +68,7 @@ from track.event_transaction_utils import ( ) from xmodule.modulestore.django import modulestore from xmodule.util.misc import get_default_short_labeler +import six log = logging.getLogger(__name__) @@ -740,8 +742,8 @@ class GradebookBulkUpdateView(GradeViewMixin, PaginatedAPIView): only_if_higher=False, expected_modified_time=to_timestamp(override.modified), score_deleted=False, - event_transaction_id=unicode(get_event_transaction_id()), - event_transaction_type=unicode(get_event_transaction_type()), + event_transaction_id=six.text_type(get_event_transaction_id()), + event_transaction_type=six.text_type(get_event_transaction_type()), score_db_table=grades_constants.ScoreDatabaseTableEnum.overrides, force_update_subsections=True, ) diff --git a/lms/djangoapps/grades/rest_api/v1/tests/mixins.py b/lms/djangoapps/grades/rest_api/v1/tests/mixins.py index 66444a376b..99fbc9a448 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/mixins.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/mixins.py @@ -1,6 +1,7 @@ """ Mixins classes being used by all test classes within this folder """ +from __future__ import absolute_import from datetime import datetime from pytz import UTC @@ -10,6 +11,7 @@ from openedx.core.djangoapps.content.course_overviews.tests.factories import Cou from student.tests.factories import CourseEnrollmentFactory, UserFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase, TEST_DATA_SPLIT_MODULESTORE +from six.moves import range class GradeViewTestMixin(SharedModuleStoreTestCase): @@ -98,7 +100,7 @@ class GradeViewTestMixin(SharedModuleStoreTestCase): # create a problem for each type and minimum count needed by the grading policy # A section is not considered if the student answers less than "min_count" problems for grading_type, min_count in (("Homework", 12), ("Lab", 12), ("Midterm Exam", 1), ("Final Exam", 1)): - for num in xrange(min_count): + for num in range(min_count): section = ItemFactory.create( category='sequential', parent_location=chapter.location, diff --git a/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py b/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py index 4fdef8d0d3..51127a9c38 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py @@ -3,6 +3,7 @@ Tests for the course grading API view """ from __future__ import unicode_literals +from __future__ import absolute_import import json from collections import OrderedDict, namedtuple from datetime import datetime diff --git a/lms/djangoapps/grades/rest_api/v1/tests/test_grading_policy_view.py b/lms/djangoapps/grades/rest_api/v1/tests/test_grading_policy_view.py index 8b9e2f0044..5ce9b5a316 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/test_grading_policy_view.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/test_grading_policy_view.py @@ -1,6 +1,7 @@ """ Tests for the views """ +from __future__ import absolute_import from datetime import datetime import ddt @@ -14,6 +15,7 @@ from student.tests.factories import UserFactory from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +import six @ddt.ddt @@ -36,7 +38,7 @@ class GradingPolicyTestMixin(object): def create_course_data(cls): cls.invalid_course_id = 'foo/bar/baz' cls.course = CourseFactory.create(display_name='An Introduction to API Testing', raw_grader=cls.raw_grader) - cls.course_id = unicode(cls.course.id) + cls.course_id = six.text_type(cls.course.id) with cls.store.bulk_operations(cls.course.id, emit_signals=False): cls.sequential = ItemFactory.create( category="sequential", @@ -150,7 +152,7 @@ class GradingPolicyTestMixin(object): org="MTD", default_store=modulestore_type, ) - self.assert_get_for_course(course_id=unicode(course.id)) + self.assert_get_for_course(course_id=six.text_type(course.id)) class CourseGradingPolicyTests(GradingPolicyTestMixin, SharedModuleStoreTestCase): diff --git a/lms/djangoapps/grades/rest_api/v1/tests/test_views.py b/lms/djangoapps/grades/rest_api/v1/tests/test_views.py index 8a29ff6d5e..3817b9d675 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/test_views.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/test_views.py @@ -2,6 +2,7 @@ Tests for v1 views """ from __future__ import unicode_literals +from __future__ import absolute_import from collections import OrderedDict import ddt diff --git a/lms/djangoapps/grades/rest_api/v1/urls.py b/lms/djangoapps/grades/rest_api/v1/urls.py index 70d646a2ad..6a498694d7 100644 --- a/lms/djangoapps/grades/rest_api/v1/urls.py +++ b/lms/djangoapps/grades/rest_api/v1/urls.py @@ -1,4 +1,5 @@ """ Grades API v1 URLs. """ +from __future__ import absolute_import from django.conf import settings from django.conf.urls import url diff --git a/lms/djangoapps/grades/rest_api/v1/utils.py b/lms/djangoapps/grades/rest_api/v1/utils.py index 9303465597..eb9d74583e 100644 --- a/lms/djangoapps/grades/rest_api/v1/utils.py +++ b/lms/djangoapps/grades/rest_api/v1/utils.py @@ -1,6 +1,7 @@ """ Define some view level utility functions here that multiple view modules will share """ +from __future__ import absolute_import from contextlib import contextmanager from django.contrib.auth import get_user_model diff --git a/lms/djangoapps/grades/rest_api/v1/views.py b/lms/djangoapps/grades/rest_api/v1/views.py index b32405eee0..34ac908596 100644 --- a/lms/djangoapps/grades/rest_api/v1/views.py +++ b/lms/djangoapps/grades/rest_api/v1/views.py @@ -1,4 +1,5 @@ """ API v0 views. """ +from __future__ import absolute_import import logging from contextlib import contextmanager