From 54de24596e155998f89f8b2bc31418eeb00c45ef Mon Sep 17 00:00:00 2001 From: Anthony Wee Date: Tue, 7 May 2019 08:14:23 -0700 Subject: [PATCH] INCR-114: Run python-modernize on openedx/core/djangoapps/auth_exchange (#20442) * INCR-114: Run python-modernize on openedx/core/djangoapps/auth_exchange * isort --- openedx/core/djangoapps/auth_exchange/forms.py | 2 ++ .../core/djangoapps/auth_exchange/tests/mixins.py | 3 +++ .../djangoapps/auth_exchange/tests/test_forms.py | 8 +++++--- .../djangoapps/auth_exchange/tests/test_views.py | 15 +++++++++------ .../core/djangoapps/auth_exchange/tests/utils.py | 5 +++-- openedx/core/djangoapps/auth_exchange/views.py | 2 ++ 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/openedx/core/djangoapps/auth_exchange/forms.py b/openedx/core/djangoapps/auth_exchange/forms.py index 6c18e10a69..b8940660c4 100644 --- a/openedx/core/djangoapps/auth_exchange/forms.py +++ b/openedx/core/djangoapps/auth_exchange/forms.py @@ -1,6 +1,8 @@ """ Forms to support third-party to first-party OAuth 2.0 access token exchange """ +from __future__ import absolute_import + import provider.constants from django.contrib.auth.models import User from django.forms import CharField diff --git a/openedx/core/djangoapps/auth_exchange/tests/mixins.py b/openedx/core/djangoapps/auth_exchange/tests/mixins.py index 6ddd305380..18bbb43bd2 100644 --- a/openedx/core/djangoapps/auth_exchange/tests/mixins.py +++ b/openedx/core/djangoapps/auth_exchange/tests/mixins.py @@ -3,7 +3,10 @@ Mixins to facilitate testing OAuth connections to Django-OAuth-Toolkit or Django-OAuth2-Provider. """ +from __future__ import absolute_import + from unittest import expectedFailure + from django.test.client import RequestFactory from openedx.core.djangoapps.oauth_dispatch import adapters diff --git a/openedx/core/djangoapps/auth_exchange/tests/test_forms.py b/openedx/core/djangoapps/auth_exchange/tests/test_forms.py index b13d343a88..3aafbe989e 100644 --- a/openedx/core/djangoapps/auth_exchange/tests/test_forms.py +++ b/openedx/core/djangoapps/auth_exchange/tests/test_forms.py @@ -2,21 +2,23 @@ """ Tests for OAuth token exchange forms """ +from __future__ import absolute_import + import unittest +import httpretty +import social_django.utils as social_utils from django.contrib.sessions.middleware import SessionMiddleware from django.test import TestCase from django.test.client import RequestFactory -import httpretty from provider import scope from social_django.models import Partial -import social_django.utils as social_utils from third_party_auth.tests.utils import ThirdPartyOAuthTestMixinFacebook, ThirdPartyOAuthTestMixinGoogle from ..forms import AccessTokenExchangeForm -from .utils import AccessTokenExchangeTestMixin, TPA_FEATURE_ENABLED, TPA_FEATURES_KEY from .mixins import DOPAdapterMixin, DOTAdapterMixin +from .utils import TPA_FEATURE_ENABLED, TPA_FEATURES_KEY, AccessTokenExchangeTestMixin class AccessTokenExchangeFormTest(AccessTokenExchangeTestMixin): diff --git a/openedx/core/djangoapps/auth_exchange/tests/test_views.py b/openedx/core/djangoapps/auth_exchange/tests/test_views.py index 8905d7951e..3d120de248 100644 --- a/openedx/core/djangoapps/auth_exchange/tests/test_views.py +++ b/openedx/core/djangoapps/auth_exchange/tests/test_views.py @@ -4,17 +4,19 @@ Tests for OAuth token exchange views # pylint: disable=no-member -from datetime import timedelta +from __future__ import absolute_import + import json -import mock import unittest +from datetime import timedelta import ddt -from django.conf import settings -from django.urls import reverse -from django.test import TestCase import httpretty +import mock import provider.constants +from django.conf import settings +from django.test import TestCase +from django.urls import reverse from provider.oauth2.models import AccessToken, Client from rest_framework.test import APIClient from social_django.models import Partial @@ -22,8 +24,9 @@ from social_django.models import Partial from openedx.core.djangoapps.oauth_dispatch.tests import factories as dot_factories from student.tests.factories import UserFactory from third_party_auth.tests.utils import ThirdPartyOAuthTestMixinFacebook, ThirdPartyOAuthTestMixinGoogle + from .mixins import DOPAdapterMixin, DOTAdapterMixin -from .utils import AccessTokenExchangeTestMixin, TPA_FEATURE_ENABLED, TPA_FEATURES_KEY +from .utils import TPA_FEATURE_ENABLED, TPA_FEATURES_KEY, AccessTokenExchangeTestMixin @ddt.ddt diff --git a/openedx/core/djangoapps/auth_exchange/tests/utils.py b/openedx/core/djangoapps/auth_exchange/tests/utils.py index db6fa91c1b..377641286a 100644 --- a/openedx/core/djangoapps/auth_exchange/tests/utils.py +++ b/openedx/core/djangoapps/auth_exchange/tests/utils.py @@ -2,12 +2,13 @@ Test utilities for OAuth access token exchange """ +from __future__ import absolute_import + from django.conf import settings -from social_django.models import UserSocialAuth, Partial +from social_django.models import Partial, UserSocialAuth from third_party_auth.tests.utils import ThirdPartyOAuthTestMixin - TPA_FEATURES_KEY = 'ENABLE_THIRD_PARTY_AUTH' TPA_FEATURE_ENABLED = TPA_FEATURES_KEY in settings.FEATURES diff --git a/openedx/core/djangoapps/auth_exchange/views.py b/openedx/core/djangoapps/auth_exchange/views.py index 4f6b9f1ad2..b3ebad2dfb 100644 --- a/openedx/core/djangoapps/auth_exchange/views.py +++ b/openedx/core/djangoapps/auth_exchange/views.py @@ -9,6 +9,8 @@ The following are currently implemented: # pylint: disable=abstract-method +from __future__ import absolute_import + import django.contrib.auth as auth import social_django.utils as social_utils from django.conf import settings