From 6dc70a675836f8c10168e9528503ee79914a6016 Mon Sep 17 00:00:00 2001 From: Stu Young <estute@users.noreply.github.com> Date: Thu, 16 May 2019 14:42:22 -0400 Subject: [PATCH] incr-310 (#20615) * run python modernize * run isort * Add oauth2_handler module docstring. --- lms/djangoapps/oauth2_handler/__init__.py | 4 ++++ lms/djangoapps/oauth2_handler/handlers.py | 5 ++++- lms/djangoapps/oauth2_handler/tests.py | 7 +++++-- lms/djangoapps/staticbook/tests.py | 2 ++ lms/djangoapps/staticbook/views.py | 4 +++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/oauth2_handler/__init__.py b/lms/djangoapps/oauth2_handler/__init__.py index fe4953f6ac5..bb3f7ed55a0 100644 --- a/lms/djangoapps/oauth2_handler/__init__.py +++ b/lms/djangoapps/oauth2_handler/__init__.py @@ -1 +1,5 @@ +""" Handlers for OpenID Connect provider. """ + +from __future__ import absolute_import + from oauth2_handler.handlers import IDTokenHandler, UserInfoHandler diff --git a/lms/djangoapps/oauth2_handler/handlers.py b/lms/djangoapps/oauth2_handler/handlers.py index da7f44043da..c8b8ad9211f 100644 --- a/lms/djangoapps/oauth2_handler/handlers.py +++ b/lms/djangoapps/oauth2_handler/handlers.py @@ -1,5 +1,8 @@ """ Handlers for OpenID Connect provider. """ +from __future__ import absolute_import + +import six from django.conf import settings from django.core.cache import cache @@ -209,7 +212,7 @@ class CourseAccessHandler(object): if not GlobalStaff().has_user(user): course_keys = [course_key for course_key in course_keys if has_access(user, access_type, course_key)] - course_ids = [unicode(course_key) for course_key in course_keys] + course_ids = [six.text_type(course_key) for course_key in course_keys] cache.set(key, course_ids, self.COURSE_CACHE_TIMEOUT) diff --git a/lms/djangoapps/oauth2_handler/tests.py b/lms/djangoapps/oauth2_handler/tests.py index b8148d7c074..169eef8955a 100644 --- a/lms/djangoapps/oauth2_handler/tests.py +++ b/lms/djangoapps/oauth2_handler/tests.py @@ -1,5 +1,8 @@ # pylint: disable=missing-docstring +from __future__ import absolute_import + import mock +import six from django.core.cache import cache from django.test.utils import override_settings # Will also run default tests for IDTokens and UserInfo @@ -21,7 +24,7 @@ class BaseTestMixin(ModuleStoreTestCase): def setUp(self): super(BaseTestMixin, self).setUp() self.course_key = CourseFactory.create(emit_signals=True).id - self.course_id = unicode(self.course_key) + self.course_id = six.text_type(self.course_key) self.user_factory = UserFactory self.set_user(self.make_user()) @@ -106,7 +109,7 @@ class IDTokenTest(BaseTestMixin, IDTokenTestCase): def test_course_staff_courses_with_claims(self): CourseStaffRole(self.course_key).add_users(self.user) - course_id = unicode(self.course_key) + course_id = six.text_type(self.course_key) nonexistent_course_id = 'some/other/course' diff --git a/lms/djangoapps/staticbook/tests.py b/lms/djangoapps/staticbook/tests.py index e8c62ac321e..aaaedc0a04b 100644 --- a/lms/djangoapps/staticbook/tests.py +++ b/lms/djangoapps/staticbook/tests.py @@ -2,6 +2,8 @@ Test the lms/staticbook views. """ +from __future__ import absolute_import + import textwrap import mock diff --git a/lms/djangoapps/staticbook/views.py b/lms/djangoapps/staticbook/views.py index 2137a30678a..2e0e33198b5 100644 --- a/lms/djangoapps/staticbook/views.py +++ b/lms/djangoapps/staticbook/views.py @@ -2,9 +2,11 @@ Views for serving static textbooks. """ +from __future__ import absolute_import + from django.contrib.auth.decorators import login_required -from django.views.decorators.clickjacking import xframe_options_exempt from django.http import Http404 +from django.views.decorators.clickjacking import xframe_options_exempt from opaque_keys.edx.keys import CourseKey from courseware.access import has_access -- GitLab