From ccff822a28ab8ac56d549c45eb69920a0f39edfd Mon Sep 17 00:00:00 2001 From: aarif Date: Thu, 11 Jul 2019 15:20:23 +0500 Subject: [PATCH] ran python-modernize and isort on files mentioned in INCR-396 --- common/djangoapps/third_party_auth/tests/test_admin.py | 4 +++- common/djangoapps/third_party_auth/tests/test_lti.py | 2 ++ common/djangoapps/third_party_auth/tests/test_settings.py | 3 ++- common/djangoapps/third_party_auth/tests/test_utils.py | 5 ++++- common/djangoapps/third_party_auth/tests/test_views.py | 2 ++ common/djangoapps/third_party_auth/tests/testutil.py | 7 +++++-- common/djangoapps/third_party_auth/tests/utils.py | 8 +++++--- 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/common/djangoapps/third_party_auth/tests/test_admin.py b/common/djangoapps/third_party_auth/tests/test_admin.py index e80ec30428..719dc0d0e6 100644 --- a/common/djangoapps/third_party_auth/tests/test_admin.py +++ b/common/djangoapps/third_party_auth/tests/test_admin.py @@ -1,12 +1,14 @@ """ Tests third_party_auth admin views """ +from __future__ import absolute_import + import unittest from django.contrib.admin.sites import AdminSite from django.core.files.uploadedfile import SimpleUploadedFile -from django.urls import reverse from django.forms import models +from django.urls import reverse from student.tests.factories import UserFactory from third_party_auth.admin import OAuth2ProviderConfigAdmin diff --git a/common/djangoapps/third_party_auth/tests/test_lti.py b/common/djangoapps/third_party_auth/tests/test_lti.py index 2458c7df42..202a471018 100644 --- a/common/djangoapps/third_party_auth/tests/test_lti.py +++ b/common/djangoapps/third_party_auth/tests/test_lti.py @@ -2,6 +2,8 @@ Unit tests for third_party_auth LTI auth providers """ +from __future__ import absolute_import + import unittest from oauthlib.common import Request diff --git a/common/djangoapps/third_party_auth/tests/test_settings.py b/common/djangoapps/third_party_auth/tests/test_settings.py index 41954154ef..8353814e4f 100644 --- a/common/djangoapps/third_party_auth/tests/test_settings.py +++ b/common/djangoapps/third_party_auth/tests/test_settings.py @@ -1,11 +1,12 @@ """Unit tests for settings.py.""" +from __future__ import absolute_import + import unittest from third_party_auth import provider, settings from third_party_auth.tests import testutil - _ORIGINAL_AUTHENTICATION_BACKENDS = ['first_authentication_backend'] _ORIGINAL_INSTALLED_APPS = ['first_installed_app'] _ORIGINAL_MIDDLEWARE_CLASSES = ['first_middleware_class'] diff --git a/common/djangoapps/third_party_auth/tests/test_utils.py b/common/djangoapps/third_party_auth/tests/test_utils.py index a6d509ed85..7eef060940 100644 --- a/common/djangoapps/third_party_auth/tests/test_utils.py +++ b/common/djangoapps/third_party_auth/tests/test_utils.py @@ -1,12 +1,15 @@ """ Tests for third_party_auth utility functions. """ +from __future__ import absolute_import + import unittest from django.conf import settings + +from student.tests.factories import UserFactory from third_party_auth.tests.testutil import TestCase from third_party_auth.utils import user_exists -from student.tests.factories import UserFactory @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') diff --git a/common/djangoapps/third_party_auth/tests/test_views.py b/common/djangoapps/third_party_auth/tests/test_views.py index 5bc78c4dfd..ada67255da 100644 --- a/common/djangoapps/third_party_auth/tests/test_views.py +++ b/common/djangoapps/third_party_auth/tests/test_views.py @@ -2,6 +2,8 @@ Test the views served by third_party_auth. """ +from __future__ import absolute_import + import unittest import ddt diff --git a/common/djangoapps/third_party_auth/tests/testutil.py b/common/djangoapps/third_party_auth/tests/testutil.py index 3ae3cc23df..616b778bea 100644 --- a/common/djangoapps/third_party_auth/tests/testutil.py +++ b/common/djangoapps/third_party_auth/tests/testutil.py @@ -4,11 +4,14 @@ Utilities for writing third_party_auth tests. Used by Django and non-Django tests; must not have Django deps. """ +from __future__ import absolute_import + import os.path from contextlib import contextmanager import django.test import mock +import six from django.conf import settings from django.contrib.auth.models import User from django.contrib.sites.models import Site @@ -17,7 +20,6 @@ from provider import constants from provider.oauth2.models import Client as OAuth2Client from storages.backends.overwrite import OverwriteStorage -from third_party_auth.models import cache as config_cache from third_party_auth.models import ( LTIProviderConfig, OAuth2ProviderConfig, @@ -25,6 +27,7 @@ from third_party_auth.models import ( SAMLConfiguration, SAMLProviderConfig ) +from third_party_auth.models import cache as config_cache AUTH_FEATURES_KEY = 'ENABLE_THIRD_PARTY_AUTH' AUTH_FEATURE_ENABLED = AUTH_FEATURES_KEY in settings.FEATURES @@ -47,7 +50,7 @@ class FakeDjangoSettings(object): def __init__(self, mappings): """Initializes the fake from mappings dict.""" - for key, value in mappings.iteritems(): + for key, value in six.iteritems(mappings): setattr(self, key, value) diff --git a/common/djangoapps/third_party_auth/tests/utils.py b/common/djangoapps/third_party_auth/tests/utils.py index a00ce7917b..e22287318c 100644 --- a/common/djangoapps/third_party_auth/tests/utils.py +++ b/common/djangoapps/third_party_auth/tests/utils.py @@ -1,14 +1,16 @@ """Common utility for testing third party oauth2 features.""" +from __future__ import absolute_import + import json from base64 import b64encode import httpretty from onelogin.saml2.utils import OneLogin_Saml2_Utils - from provider.constants import PUBLIC from provider.oauth2.models import Client -from social_core.backends.facebook import FacebookOAuth2, API_VERSION as FACEBOOK_API_VERSION -from social_django.models import UserSocialAuth, Partial +from social_core.backends.facebook import API_VERSION as FACEBOOK_API_VERSION +from social_core.backends.facebook import FacebookOAuth2 +from social_django.models import Partial, UserSocialAuth from student.tests.factories import UserFactory