From 2e305964f5149485d9c4e000818e06cba55334a3 Mon Sep 17 00:00:00 2001 From: Guruprasad Lakshmi Narayanan Date: Thu, 28 Mar 2019 15:26:31 -0700 Subject: [PATCH] [INCR-180] Compatibility changes - openedx/core/djangoapps/theming/tests --- .../djangoapps/theming/tests/test_commands.py | 4 +++- .../djangoapps/theming/tests/test_finders.py | 2 ++ .../djangoapps/theming/tests/test_helpers.py | 16 +++++++++++----- .../djangoapps/theming/tests/test_microsites.py | 4 +++- .../djangoapps/theming/tests/test_middleware.py | 5 ++++- .../djangoapps/theming/tests/test_storage.py | 11 ++++++----- .../theming/tests/test_theme_locales.py | 2 ++ .../theming/tests/test_theme_style_overrides.py | 6 ++++-- .../core/djangoapps/theming/tests/test_util.py | 9 ++++----- .../core/djangoapps/theming/tests/test_views.py | 7 +++++-- 10 files changed, 44 insertions(+), 22 deletions(-) diff --git a/openedx/core/djangoapps/theming/tests/test_commands.py b/openedx/core/djangoapps/theming/tests/test_commands.py index 163c0de8e0..7b4563c0bb 100644 --- a/openedx/core/djangoapps/theming/tests/test_commands.py +++ b/openedx/core/djangoapps/theming/tests/test_commands.py @@ -1,8 +1,10 @@ """ Tests for Management commands of comprehensive theming. """ +from __future__ import absolute_import + +from django.core.management import CommandError, call_command from django.test import TestCase -from django.core.management import call_command, CommandError from openedx.core.djangoapps.theming.helpers import get_themes from openedx.core.djangoapps.theming.management.commands.compile_sass import Command diff --git a/openedx/core/djangoapps/theming/tests/test_finders.py b/openedx/core/djangoapps/theming/tests/test_finders.py index f429f0f259..38db438ff9 100644 --- a/openedx/core/djangoapps/theming/tests/test_finders.py +++ b/openedx/core/djangoapps/theming/tests/test_finders.py @@ -2,6 +2,8 @@ Tests for comprehensive theme static files finders. """ +from __future__ import absolute_import + from django.conf import settings from django.test import TestCase diff --git a/openedx/core/djangoapps/theming/tests/test_helpers.py b/openedx/core/djangoapps/theming/tests/test_helpers.py index afde716822..28bf55e8d0 100644 --- a/openedx/core/djangoapps/theming/tests/test_helpers.py +++ b/openedx/core/djangoapps/theming/tests/test_helpers.py @@ -1,17 +1,23 @@ """ Test helpers for Comprehensive Theming. """ -from mock import patch, Mock +from __future__ import absolute_import -from django.test import TestCase, override_settings from django.conf import settings +from django.test import TestCase, override_settings from edx_django_utils.cache import RequestCache +from mock import Mock, patch -from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers from openedx.core.djangoapps.theming import helpers as theming_helpers -from openedx.core.djangoapps.theming.helpers import get_template_path_with_theme, strip_site_theme_templates_path, \ - get_themes, Theme, get_theme_base_dir +from openedx.core.djangoapps.theming.helpers import ( + Theme, + get_template_path_with_theme, + get_theme_base_dir, + get_themes, + strip_site_theme_templates_path +) +from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme from openedx.core.djangolib.testing.utils import skip_unless_cms, skip_unless_lms diff --git a/openedx/core/djangoapps/theming/tests/test_microsites.py b/openedx/core/djangoapps/theming/tests/test_microsites.py index 1cb6c007af..45ac476ef7 100644 --- a/openedx/core/djangoapps/theming/tests/test_microsites.py +++ b/openedx/core/djangoapps/theming/tests/test_microsites.py @@ -1,9 +1,11 @@ """ Tests for microsites and comprehensive themes. """ +from __future__ import absolute_import + from django.conf import settings -from django.test import TestCase from django.contrib.sites.models import Site +from django.test import TestCase from openedx.core.djangoapps.theming.models import SiteTheme from openedx.core.djangolib.testing.utils import skip_unless_lms diff --git a/openedx/core/djangoapps/theming/tests/test_middleware.py b/openedx/core/djangoapps/theming/tests/test_middleware.py index a151e02106..a71c648d42 100644 --- a/openedx/core/djangoapps/theming/tests/test_middleware.py +++ b/openedx/core/djangoapps/theming/tests/test_middleware.py @@ -2,9 +2,12 @@ Tests for middleware for comprehensive themes. """ +from __future__ import absolute_import + from django.contrib.messages.middleware import MessageMiddleware -from django.test import RequestFactory, TestCase, override_settings from django.contrib.sites.models import Site +from django.test import RequestFactory, TestCase, override_settings + from openedx.core.djangoapps.theming.middleware import CurrentSiteThemeMiddleware from student.tests.factories import UserFactory diff --git a/openedx/core/djangoapps/theming/tests/test_storage.py b/openedx/core/djangoapps/theming/tests/test_storage.py index 35409fc079..3d5170283c 100644 --- a/openedx/core/djangoapps/theming/tests/test_storage.py +++ b/openedx/core/djangoapps/theming/tests/test_storage.py @@ -1,15 +1,16 @@ """ Tests for comprehensive theme static files storage classes. """ -import ddt +from __future__ import absolute_import + import re +import ddt +from django.conf import settings +from django.test import TestCase, override_settings from mock import patch -from django.test import TestCase, override_settings -from django.conf import settings - -from openedx.core.djangoapps.theming.helpers import get_theme_base_dirs, Theme, get_theme_base_dir +from openedx.core.djangoapps.theming.helpers import Theme, get_theme_base_dir, get_theme_base_dirs from openedx.core.djangoapps.theming.storage import ThemeStorage from openedx.core.djangolib.testing.utils import skip_unless_lms diff --git a/openedx/core/djangoapps/theming/tests/test_theme_locales.py b/openedx/core/djangoapps/theming/tests/test_theme_locales.py index b79b2209b3..553e83e531 100644 --- a/openedx/core/djangoapps/theming/tests/test_theme_locales.py +++ b/openedx/core/djangoapps/theming/tests/test_theme_locales.py @@ -1,6 +1,8 @@ """ Tests for Theming locales """ +from __future__ import absolute_import + import os from django.conf import settings diff --git a/openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py b/openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py index d21846cd52..62fe295ca3 100644 --- a/openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py +++ b/openedx/core/djangoapps/theming/tests/test_theme_style_overrides.py @@ -1,10 +1,12 @@ """ Tests for comprehensive themes. """ +from __future__ import absolute_import + from django.conf import settings -from django.urls import reverse -from django.test import TestCase from django.contrib import staticfiles +from django.test import TestCase +from django.urls import reverse from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme from openedx.core.djangolib.testing.utils import skip_unless_cms, skip_unless_lms diff --git a/openedx/core/djangoapps/theming/tests/test_util.py b/openedx/core/djangoapps/theming/tests/test_util.py index 9da7deb527..603df818ff 100644 --- a/openedx/core/djangoapps/theming/tests/test_util.py +++ b/openedx/core/djangoapps/theming/tests/test_util.py @@ -1,18 +1,17 @@ """ Test helpers for Comprehensive Theming. """ -from __future__ import print_function +from __future__ import absolute_import, print_function -from functools import wraps +import contextlib import os import os.path -import contextlib import re - -from mock import patch +from functools import wraps from django.conf import settings from django.contrib.sites.models import Site +from mock import patch import edxmako from openedx.core.djangoapps.theming.models import SiteTheme diff --git a/openedx/core/djangoapps/theming/tests/test_views.py b/openedx/core/djangoapps/theming/tests/test_views.py index 9ef899ff9f..e69a0baf46 100644 --- a/openedx/core/djangoapps/theming/tests/test_views.py +++ b/openedx/core/djangoapps/theming/tests/test_views.py @@ -2,11 +2,14 @@ Tests for comprehensive them """ -from courseware.tests.factories import GlobalStaffFactory +from __future__ import absolute_import + from django.conf import settings from django.contrib.messages.middleware import MessageMiddleware -from django.test import TestCase from django.contrib.sites.models import Site +from django.test import TestCase + +from courseware.tests.factories import GlobalStaffFactory from openedx.core.djangoapps.theming.middleware import CurrentSiteThemeMiddleware from student.tests.factories import UserFactory