From c2dcbb36b7d5cb76673579448a583babbc9a9c93 Mon Sep 17 00:00:00 2001 From: Stu Young Date: Thu, 16 May 2019 13:20:28 -0400 Subject: [PATCH] incr-278 (#20581) * run python modernize * run isort * quality * qual --- .../commerce/management/commands/configure_commerce.py | 2 +- .../commands/tests/test_configure_commerce.py | 2 ++ lms/djangoapps/commerce/tests/__init__.py | 2 ++ lms/djangoapps/commerce/tests/factories.py | 2 ++ lms/djangoapps/commerce/tests/mocks.py | 5 +++-- lms/djangoapps/commerce/tests/test_signals.py | 9 +++++---- lms/djangoapps/commerce/tests/test_utils.py | 10 ++++++---- lms/djangoapps/commerce/tests/test_views.py | 2 ++ 8 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lms/djangoapps/commerce/management/commands/configure_commerce.py b/lms/djangoapps/commerce/management/commands/configure_commerce.py index 05c765c654..52f342348b 100644 --- a/lms/djangoapps/commerce/management/commands/configure_commerce.py +++ b/lms/djangoapps/commerce/management/commands/configure_commerce.py @@ -3,7 +3,7 @@ Command for managing commerce configuration for lms. We can use this command to enable/disable commerce configuration or disable checkout to E-Commerce service. """ -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import logging diff --git a/lms/djangoapps/commerce/management/commands/tests/test_configure_commerce.py b/lms/djangoapps/commerce/management/commands/tests/test_configure_commerce.py index 4e781d2d0f..71fd84bb84 100644 --- a/lms/djangoapps/commerce/management/commands/tests/test_configure_commerce.py +++ b/lms/djangoapps/commerce/management/commands/tests/test_configure_commerce.py @@ -1,6 +1,8 @@ """ Tests for management command for enabling commerce configuration. """ +from __future__ import absolute_import + from django.core.management import call_command from django.test import TestCase diff --git a/lms/djangoapps/commerce/tests/__init__.py b/lms/djangoapps/commerce/tests/__init__.py index cb7ca970a6..18b8effdf4 100644 --- a/lms/djangoapps/commerce/tests/__init__.py +++ b/lms/djangoapps/commerce/tests/__init__.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- """ Commerce app tests package. """ +from __future__ import absolute_import + import httpretty import mock from django.conf import settings diff --git a/lms/djangoapps/commerce/tests/factories.py b/lms/djangoapps/commerce/tests/factories.py index 8a124b3b5c..48eec2d2a1 100644 --- a/lms/djangoapps/commerce/tests/factories.py +++ b/lms/djangoapps/commerce/tests/factories.py @@ -1,4 +1,6 @@ """ Factories for generating fake commerce-related data. """ +from __future__ import absolute_import + import factory from factory.fuzzy import FuzzyText diff --git a/lms/djangoapps/commerce/tests/mocks.py b/lms/djangoapps/commerce/tests/mocks.py index a22cc69baf..f092d5c0a8 100644 --- a/lms/djangoapps/commerce/tests/mocks.py +++ b/lms/djangoapps/commerce/tests/mocks.py @@ -1,4 +1,7 @@ """ Commerce app tests package. """ +# pylint: disable=invalid-name +from __future__ import absolute_import + import json import httpretty @@ -7,8 +10,6 @@ from django.conf import settings from . import factories -# pylint: disable=invalid-name - class mock_ecommerce_api_endpoint(object): """ Base class for contextmanagers used to mock calls to api endpoints. diff --git a/lms/djangoapps/commerce/tests/test_signals.py b/lms/djangoapps/commerce/tests/test_signals.py index 358fc038d6..95a8f21bc1 100644 --- a/lms/djangoapps/commerce/tests/test_signals.py +++ b/lms/djangoapps/commerce/tests/test_signals.py @@ -2,11 +2,10 @@ """ Tests for signal handling in commerce djangoapp. """ -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import base64 import json -from urlparse import urljoin import ddt import httpretty @@ -17,14 +16,16 @@ from django.test import TestCase from django.test.utils import override_settings from opaque_keys.edx.keys import CourseKey from requests import Timeout +from six.moves.urllib.parse import urljoin # pylint: disable=import-error from course_modes.models import CourseMode from student.signals import REFUND_ORDER from student.tests.factories import CourseEnrollmentFactory, UserFactory + +from ..models import CommerceConfiguration +from ..utils import _generate_refund_notification_body, _send_refund_notification, create_zendesk_ticket from . import JSON from .mocks import mock_create_refund, mock_process_refund -from ..models import CommerceConfiguration -from ..utils import create_zendesk_ticket, _generate_refund_notification_body, _send_refund_notification ZENDESK_URL = 'http://zendesk.example.com/' ZENDESK_USER = 'test@example.com' diff --git a/lms/djangoapps/commerce/tests/test_utils.py b/lms/djangoapps/commerce/tests/test_utils.py index fe72978e5f..1f2619cde2 100644 --- a/lms/djangoapps/commerce/tests/test_utils.py +++ b/lms/djangoapps/commerce/tests/test_utils.py @@ -1,6 +1,7 @@ """Tests of commerce utilities.""" +from __future__ import absolute_import + import json -from urllib import urlencode import ddt import httpretty @@ -10,9 +11,8 @@ from django.test.client import RequestFactory from django.test.utils import override_settings from mock import patch from opaque_keys.edx.locator import CourseLocator +from six.moves.urllib.parse import urlencode # pylint: disable=import-error from waffle.testutils import override_switch -from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory from course_modes.models import CourseMode from course_modes.tests.factories import CourseModeFactory @@ -21,7 +21,9 @@ from lms.djangoapps.commerce.utils import EcommerceService, refund_entitlement, from openedx.core.djangolib.testing.utils import skip_unless_lms from openedx.core.lib.log_utils import audit_log from student.models import CourseEnrollment -from student.tests.factories import (TEST_PASSWORD, UserFactory) +from student.tests.factories import TEST_PASSWORD, UserFactory +from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase +from xmodule.modulestore.tests.factories import CourseFactory # Entitlements is not in CMS' INSTALLED_APPS so these imports will error during test collection if settings.ROOT_URLCONF == 'lms.urls': diff --git a/lms/djangoapps/commerce/tests/test_views.py b/lms/djangoapps/commerce/tests/test_views.py index 1437ca3bbe..63498cfd4e 100644 --- a/lms/djangoapps/commerce/tests/test_views.py +++ b/lms/djangoapps/commerce/tests/test_views.py @@ -1,5 +1,7 @@ """ Tests for commerce views. """ +from __future__ import absolute_import + import json import ddt