Use full names for common.djangoapps imports; warn when using old style (#25477)

* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
This commit is contained in:
Kyle McCormick
2020-11-10 07:02:01 -05:00
committed by GitHub
parent a62c5dad49
commit 151bd13666
1707 changed files with 6132 additions and 2430 deletions

View File

@@ -10,7 +10,7 @@ from factory import lazy_attribute
from factory.django import DjangoModelFactory
from opaque_keys.edx.keys import CourseKey
from course_modes.models import CourseMode
from common.djangoapps.course_modes.models import CourseMode
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory

View File

@@ -12,17 +12,17 @@ from django.conf import settings
from django.urls import reverse
from pytz import UTC, timezone
from course_modes.admin import CourseModeForm
from course_modes.models import CourseMode
from course_modes.tests.factories import CourseModeFactory
from common.djangoapps.course_modes.admin import CourseModeForm
from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
# Technically, we shouldn't be importing verify_student, since it's
# defined in the LMS and course_modes is in common. However, the benefits
# of putting all this configuration in one place outweigh the downsides.
# Once the course admin tool is deployed, we can remove this dependency.
from lms.djangoapps.verify_student.models import VerificationDeadline
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from student.tests.factories import UserFactory
from util.date_utils import get_time_display
from common.djangoapps.student.tests.factories import UserFactory
from common.djangoapps.util.date_utils import get_time_display
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory

View File

@@ -18,9 +18,9 @@ from opaque_keys.edx.locator import CourseLocator
import six
from six.moves import zip
from course_modes.helpers import enrollment_mode_display
from course_modes.models import CourseMode, Mode, get_cosmetic_display_price, invalidate_course_mode_cache
from course_modes.tests.factories import CourseModeFactory
from common.djangoapps.course_modes.helpers import enrollment_mode_display
from common.djangoapps.course_modes.models import CourseMode, Mode, get_cosmetic_display_price, invalidate_course_mode_cache
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@@ -546,12 +546,18 @@ class TestDisplayPrices(ModuleStoreTestCase):
course = CourseFactory.create()
registration_price = 99
course.cosmetic_display_price = 10
with patch('course_modes.models.CourseMode.min_course_price_for_currency', return_value=registration_price):
with patch(
'common.djangoapps.course_modes.models.CourseMode.min_course_price_for_currency',
return_value=registration_price,
):
# Since registration_price is set, it overrides the cosmetic_display_price and should be returned
self.assertEqual(get_cosmetic_display_price(course), "$99")
registration_price = 0
with patch('course_modes.models.CourseMode.min_course_price_for_currency', return_value=registration_price):
with patch(
'common.djangoapps.course_modes.models.CourseMode.min_course_price_for_currency',
return_value=registration_price,
):
# Since registration_price is not set, cosmetic_display_price should be returned
self.assertEqual(get_cosmetic_display_price(course), "$10")

View File

@@ -10,8 +10,8 @@ from django.conf import settings
from mock import patch
from pytz import UTC
from course_modes.models import CourseMode
from course_modes.signals import _listen_for_course_publish
from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.course_modes.signals import _listen_for_course_publish
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
@@ -67,7 +67,7 @@ class CourseModeSignalTest(ModuleStoreTestCase):
course_mode, __ = self.create_mode('verified', 'verified', 10)
self.assertIsNone(course_mode.expiration_datetime)
with patch('course_modes.models.CourseModeExpirationConfig.current') as config:
with patch('common.djangoapps.course_modes.models.CourseModeExpirationConfig.current') as config:
instance = config.return_value
instance.verification_window = timedelta(days=verification_window)
@@ -83,7 +83,7 @@ class CourseModeSignalTest(ModuleStoreTestCase):
course_mode.expiration_datetime_is_explicit = True
self.assertIsNone(course_mode.expiration_datetime)
with patch('course_modes.models.CourseModeExpirationConfig.current') as config:
with patch('common.djangoapps.course_modes.models.CourseModeExpirationConfig.current') as config:
instance = config.return_value
instance.verification_window = timedelta(days=verification_window)

View File

@@ -16,17 +16,17 @@ from django.conf import settings
from django.urls import reverse
from mock import patch
from course_modes.models import CourseMode, Mode
from course_modes.tests.factories import CourseModeFactory
from common.djangoapps.course_modes.models import CourseMode, Mode
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
from lms.djangoapps.commerce.tests import test_utils as ecomm_test_utils
from lms.djangoapps.commerce.tests.mocks import mock_payment_processors
from openedx.core.djangoapps.catalog.tests.mixins import CatalogIntegrationMixin
from openedx.core.djangoapps.embargo.test_utils import restrict_course
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
from student.models import CourseEnrollment
from student.tests.factories import CourseEnrollmentFactory, UserFactory
from util.testing import UrlResetMixin
from util.tests.mixins.discovery import CourseCatalogServiceMockMixin
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
from common.djangoapps.util.testing import UrlResetMixin
from common.djangoapps.util.tests.mixins.discovery import CourseCatalogServiceMockMixin
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@@ -38,7 +38,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
"""
Course Mode View tests
"""
URLCONF_MODULES = ['course_modes.urls']
URLCONF_MODULES = ['common.djangoapps.course_modes.urls']
@patch.dict(settings.FEATURES, {'MODE_CREATION_FOR_TESTING': True})
def setUp(self):
@@ -200,8 +200,8 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
self.assertNotContains(response, "Credit")
@httpretty.activate
@patch('course_modes.views.enterprise_customer_for_request')
@patch('course_modes.views.get_course_final_price')
@patch('common.djangoapps.course_modes.views.enterprise_customer_for_request')
@patch('common.djangoapps.course_modes.views.get_course_final_price')
@ddt.data(
(1.0, True),
(50.0, False),