From e87dc6cc778fc2d2609e9b986f04274367619298 Mon Sep 17 00:00:00 2001 From: arbisoft Date: Thu, 11 Jul 2019 14:24:38 +0500 Subject: [PATCH] Fixing python-modernize issues. --- common/djangoapps/third_party_auth/api/permissions.py | 2 ++ common/djangoapps/third_party_auth/api/serializers.py | 2 ++ .../third_party_auth/api/tests/test_permissions.py | 10 ++++++---- .../third_party_auth/api/tests/test_views.py | 10 ++++++---- common/djangoapps/third_party_auth/api/urls.py | 3 ++- common/djangoapps/third_party_auth/api/views.py | 2 ++ .../third_party_auth/management/commands/saml.py | 6 +++++- 7 files changed, 25 insertions(+), 10 deletions(-) diff --git a/common/djangoapps/third_party_auth/api/permissions.py b/common/djangoapps/third_party_auth/api/permissions.py index 8b59eafe51..757a04385d 100644 --- a/common/djangoapps/third_party_auth/api/permissions.py +++ b/common/djangoapps/third_party_auth/api/permissions.py @@ -1,6 +1,8 @@ """ Third party auth API related permissions """ +from __future__ import absolute_import + from rest_framework import permissions from third_party_auth.models import ProviderApiPermissions diff --git a/common/djangoapps/third_party_auth/api/serializers.py b/common/djangoapps/third_party_auth/api/serializers.py index 7e1683e0f0..245381199c 100644 --- a/common/djangoapps/third_party_auth/api/serializers.py +++ b/common/djangoapps/third_party_auth/api/serializers.py @@ -1,5 +1,7 @@ """ Django REST Framework Serializers """ +from __future__ import absolute_import + from rest_framework import serializers diff --git a/common/djangoapps/third_party_auth/api/tests/test_permissions.py b/common/djangoapps/third_party_auth/api/tests/test_permissions.py index bcae71f915..0e3d0c4378 100644 --- a/common/djangoapps/third_party_auth/api/tests/test_permissions.py +++ b/common/djangoapps/third_party_auth/api/tests/test_permissions.py @@ -1,14 +1,16 @@ """ Tests for the Third Party Auth permissions """ +from __future__ import absolute_import + import unittest + import ddt -from mock import Mock - -from rest_framework.test import APITestCase from django.conf import settings -from third_party_auth.api.permissions import ThirdPartyAuthProviderApiPermission +from mock import Mock +from rest_framework.test import APITestCase +from third_party_auth.api.permissions import ThirdPartyAuthProviderApiPermission from third_party_auth.tests.testutil import ThirdPartyAuthTestMixin IDP_SLUG_TESTSHIB = 'testshib' diff --git a/common/djangoapps/third_party_auth/api/tests/test_views.py b/common/djangoapps/third_party_auth/api/tests/test_views.py index a1df08486b..95786a50dc 100644 --- a/common/djangoapps/third_party_auth/api/tests/test_views.py +++ b/common/djangoapps/third_party_auth/api/tests/test_views.py @@ -1,6 +1,8 @@ """ Tests for the Third Party Auth REST API """ +from __future__ import absolute_import + import unittest import ddt @@ -11,17 +13,17 @@ from django.test.utils import override_settings from django.urls import reverse from mock import patch from provider.constants import CONFIDENTIAL -from provider.oauth2.models import Client, AccessToken -from openedx.core.lib.api.permissions import ApiKeyHeaderPermission +from provider.oauth2.models import AccessToken, Client from rest_framework.test import APITestCase +from six.moves import range from social_django.models import UserSocialAuth +from openedx.core.lib.api.permissions import ApiKeyHeaderPermission from student.tests.factories import UserFactory from third_party_auth.api.permissions import ThirdPartyAuthProviderApiPermission from third_party_auth.models import ProviderApiPermissions from third_party_auth.tests.testutil import ThirdPartyAuthTestMixin - VALID_API_KEY = "i am a key" IDP_SLUG_TESTSHIB = 'testshib' PROVIDER_ID_TESTSHIB = 'saml-' + IDP_SLUG_TESTSHIB @@ -201,7 +203,7 @@ class UserViewAPITests(UserViewsMixin, TpaAPITestCase): """ return reverse( 'third_party_auth_users_api', - kwargs={'username': identifier.values()[0]} + kwargs={'username': list(identifier.values())[0]} ) diff --git a/common/djangoapps/third_party_auth/api/urls.py b/common/djangoapps/third_party_auth/api/urls.py index 32f2ac3cfd..c4da48933c 100644 --- a/common/djangoapps/third_party_auth/api/urls.py +++ b/common/djangoapps/third_party_auth/api/urls.py @@ -1,11 +1,12 @@ """ URL configuration for the third party auth API """ +from __future__ import absolute_import + from django.conf import settings from django.conf.urls import url from .views import ThirdPartyAuthUserStatusView, UserMappingView, UserView, UserViewV2 - PROVIDER_PATTERN = r'(?P[\w.+-]+)(?:\:(?P[\w.+-]+))?' urlpatterns = [ diff --git a/common/djangoapps/third_party_auth/api/views.py b/common/djangoapps/third_party_auth/api/views.py index 80e2060517..5c2f8e9696 100644 --- a/common/djangoapps/third_party_auth/api/views.py +++ b/common/djangoapps/third_party_auth/api/views.py @@ -2,6 +2,8 @@ Third Party Auth REST API views """ +from __future__ import absolute_import + from collections import namedtuple from django.conf import settings diff --git a/common/djangoapps/third_party_auth/management/commands/saml.py b/common/djangoapps/third_party_auth/management/commands/saml.py index 8717162a01..f9ae148cea 100644 --- a/common/djangoapps/third_party_auth/management/commands/saml.py +++ b/common/djangoapps/third_party_auth/management/commands/saml.py @@ -2,8 +2,12 @@ """ Management commands for third_party_auth """ -from django.core.management.base import BaseCommand, CommandError +from __future__ import absolute_import + import logging + +from django.core.management.base import BaseCommand, CommandError + from third_party_auth.tasks import fetch_saml_metadata