Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix failures caused by removing lms/djangoapps from sys.path
Browse files Browse the repository at this point in the history
  • Loading branch information
cpennington committed Sep 23, 2020
1 parent 211bd3b commit 4a120a9
Show file tree
Hide file tree
Showing 51 changed files with 298 additions and 282 deletions.
2 changes: 2 additions & 0 deletions cms/envs/bok_choy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from path import Path as path

from openedx.core.release import RELEASE_LINE
from xmodule.modulestore.modulestore_settings import update_module_store_settings

########################## Prod-like settings ###################################
# These should be as close as possible to the settings we use in production.
Expand All @@ -36,6 +37,7 @@

from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position


######################### Testing overrides ####################################

# Redirect to the test_root folder within the repo
Expand Down
6 changes: 3 additions & 3 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import lms.envs.common
# Although this module itself may not use these imported variables, other dependent modules may.
from lms.envs.common import (
USE_TZ, ALL_LANGUAGES, update_module_store_settings, ASSET_IGNORE_REGEX,
USE_TZ, ALL_LANGUAGES, ASSET_IGNORE_REGEX,
PARENTAL_CONSENT_AGE_LIMIT, REGISTRATION_EMAIL_PATTERNS_ALLOWED,
# The following PROFILE_IMAGE_* settings are included as they are
# indirectly accessed through the email opt-in API, which is
Expand Down Expand Up @@ -1440,7 +1440,7 @@
# by installed apps.
'openedx.core.djangoapps.oauth_dispatch.apps.OAuthDispatchAppConfig',
'lms.djangoapps.courseware',
'coursewarehistoryextended',
'lms.djangoapps.coursewarehistoryextended',
'survey.apps.SurveyConfig',
'lms.djangoapps.verify_student.apps.VerifyStudentConfig',
'completion',
Expand Down Expand Up @@ -1499,7 +1499,7 @@
'openedx.features.course_duration_limits',
'openedx.features.content_type_gating',
'openedx.features.discounts',
'experiments',
'lms.djangoapps.experiments',

'openedx.core.djangoapps.external_user_ids',
# so sample_task is available to celery workers
Expand Down
7 changes: 5 additions & 2 deletions cms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# pylint: disable=wildcard-import, unused-wildcard-import


from .common import *
import os
from uuid import uuid4

Expand All @@ -24,8 +23,12 @@
from openedx.core.lib.derived import derive_settings
from util.db import NoOpMigrationModules

from xmodule.modulestore.modulestore_settings import update_module_store_settings

from .common import *

# import settings from LMS for consistent behavior with CMS
from lms.envs.test import (
from lms.envs.test import ( # pylint: disable=wrong-import-order
COMPREHENSIVE_THEME_DIRS,
DEFAULT_FILE_STORAGE,
ECOMMERCE_API_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TestCourseVerificationStatus(UrlResetMixin, ModuleStoreTestCase):
None: None,
}

URLCONF_MODULES = ['verify_student.urls']
URLCONF_MODULES = ['lms.djangoapps.verify_student.urls']

def setUp(self):
# Invoke UrlResetMixin
Expand Down
2 changes: 1 addition & 1 deletion docs/docs_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
'course_creators',
'xblock_config.apps.XBlockConfig',
'user_tasks',
'lti_provider'
'lms.djangoapps.lti_provider'
])
9 changes: 0 additions & 9 deletions docs/guides/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,6 @@
if os.path.isdir(six.text_type(root / path)) and app != 'terrain':
modules[path] = path

# These Django apps under lms don't import correctly with the "lms.djangapps" prefix
# Others don't import correctly without it...INSTALLED_APPS entries are inconsistent
lms_djangoapps = ['badges', 'branding', 'bulk_email', 'courseware',
'coursewarehistoryextended', 'email_marketing', 'experiments', 'lti_provider',
'mobile_api', 'notes', 'rss_proxy', 'shoppingcart', 'survey']
for app in lms_djangoapps:
path = os.path.join('lms', 'djangoapps', app)
modules[path] = path


def update_settings_module(service='lms'):
"""
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/badges/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BadgesConfig(AppConfig):
"""
Application Configuration for Badges.
"""
name = u'badges'
name = u'lms.djangoapps.badges'

def ready(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/branding/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.test.utils import override_settings
from django.urls import reverse

from branding.api import _footer_business_links, get_footer, get_home_url, get_logo_url
from ..api import _footer_business_links, get_footer, get_home_url, get_logo_url
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration

test_config_disabled_contact_us = { # pylint: disable=invalid-name
Expand Down
8 changes: 8 additions & 0 deletions lms/djangoapps/bulk_email/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig


class BulkEmailConfig(AppConfig):
"""
Application Configuration for bulk_email.
"""
name = u'lms.djangoapps.bulk_email'
4 changes: 2 additions & 2 deletions lms/djangoapps/bulk_email/tests/test_course_optout.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from lms.djangoapps.bulk_email.api import get_unsubscribed_link


@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestOptoutCourseEmails(ModuleStoreTestCase):
"""
Test that optouts are referenced in sending course email.
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_optin_course(self):
self.assertIn(self.instructor.email, sent_addresses)


@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestACEOptoutCourseEmails(ModuleStoreTestCase):
"""
Test that optouts are referenced in sending course email.
Expand Down
12 changes: 6 additions & 6 deletions lms/djangoapps/bulk_email/tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from markupsafe import escape
from mock import Mock, patch

from bulk_email.models import BulkEmailFlag, Optout
from bulk_email.tasks import _get_course_email_context, _get_source_address
from ..models import BulkEmailFlag, Optout
from ..tasks import _get_course_email_context, _get_source_address
from course_modes.models import CourseMode

from lms.djangoapps.courseware.tests.factories import InstructorFactory, StaffFactory
Expand Down Expand Up @@ -166,7 +166,7 @@ def mock_ugettext(text):
text=text,
)

with patch('bulk_email.tasks._', side_effect=mock_ugettext):
with patch('lms.djangoapps.bulk_email.tasks._', side_effect=mock_ugettext):
self.client.post(self.send_mail_url, test_email)

return mail.outbox[0]
Expand Down Expand Up @@ -229,7 +229,7 @@ def test_esperanto_platform_arabic_course(self):
self.assertRegex(message.from_email, 'AR .* Course Staff')


@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase):
"""
Tests email sending with mocked html_to_text.
Expand All @@ -249,7 +249,7 @@ def test_email_disabled(self):
# We should get back a HttpResponseForbidden (status code 403)
self.assertContains(response, "Email is not enabled for this course.", status_code=403)

@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
def test_send_to_self(self):
"""
Make sure email send to myself goes to myself.
Expand Down Expand Up @@ -566,7 +566,7 @@ def test_long_course_display_name(self):
self.assertEqual(len(from_email), 61)

@override_settings(BULK_EMAIL_EMAILS_PER_TASK=3)
@patch('bulk_email.tasks.update_subtask_status')
@patch('lms.djangoapps.bulk_email.tasks.update_subtask_status')
def test_chunked_queries_send_numerous_emails(self, email_mock):
"""
Test sending a large number of emails, to test the chunked querying
Expand Down
26 changes: 13 additions & 13 deletions lms/djangoapps/bulk_email/tests/test_err_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class EmailTestException(Exception):


@ddt.ddt
@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestEmailErrors(ModuleStoreTestCase):
"""
Test that errors from sending email are handled properly.
Expand Down Expand Up @@ -75,8 +75,8 @@ def tearDownClass(cls):
super(TestEmailErrors, cls).tearDownClass()
BulkEmailFlag.objects.all().delete()

@patch('bulk_email.tasks.get_connection', autospec=True)
@patch('bulk_email.tasks.send_course_email.retry')
@patch('lms.djangoapps.bulk_email.tasks.get_connection', autospec=True)
@patch('lms.djangoapps.bulk_email.tasks.send_course_email.retry')
def test_data_err_retry(self, retry, get_conn):
"""
Test that celery handles transient SMTPDataErrors by retrying.
Expand All @@ -97,9 +97,9 @@ def test_data_err_retry(self, retry, get_conn):
exc = kwargs['exc']
self.assertIsInstance(exc, SMTPDataError)

@patch('bulk_email.tasks.get_connection', autospec=True)
@patch('bulk_email.tasks.update_subtask_status')
@patch('bulk_email.tasks.send_course_email.retry')
@patch('lms.djangoapps.bulk_email.tasks.get_connection', autospec=True)
@patch('lms.djangoapps.bulk_email.tasks.update_subtask_status')
@patch('lms.djangoapps.bulk_email.tasks.send_course_email.retry')
def test_data_err_fail(self, retry, result, get_conn):
"""
Test that celery handles permanent SMTPDataErrors by failing and not retrying.
Expand Down Expand Up @@ -130,8 +130,8 @@ def test_data_err_fail(self, retry, result, get_conn):
self.assertEqual(subtask_status.failed, expected_fails)
self.assertEqual(subtask_status.succeeded, settings.BULK_EMAIL_EMAILS_PER_TASK - expected_fails)

@patch('bulk_email.tasks.get_connection', autospec=True)
@patch('bulk_email.tasks.send_course_email.retry')
@patch('lms.djangoapps.bulk_email.tasks.get_connection', autospec=True)
@patch('lms.djangoapps.bulk_email.tasks.send_course_email.retry')
def test_disconn_err_retry(self, retry, get_conn):
"""
Test that celery handles SMTPServerDisconnected by retrying.
Expand All @@ -151,8 +151,8 @@ def test_disconn_err_retry(self, retry, get_conn):
exc = kwargs['exc']
self.assertIsInstance(exc, SMTPServerDisconnected)

@patch('bulk_email.tasks.get_connection', autospec=True)
@patch('bulk_email.tasks.send_course_email.retry')
@patch('lms.djangoapps.bulk_email.tasks.get_connection', autospec=True)
@patch('lms.djangoapps.bulk_email.tasks.send_course_email.retry')
def test_conn_err_retry(self, retry, get_conn):
"""
Test that celery handles SMTPConnectError by retrying.
Expand All @@ -173,8 +173,8 @@ def test_conn_err_retry(self, retry, get_conn):
exc = kwargs['exc']
self.assertIsInstance(exc, SMTPConnectError)

@patch('bulk_email.tasks.SubtaskStatus.increment')
@patch('bulk_email.tasks.log')
@patch('lms.djangoapps.bulk_email.tasks.SubtaskStatus.increment')
@patch('lms.djangoapps.bulk_email.tasks.log')
def test_nonexistent_email(self, mock_log, result):
"""
Tests retries when the email doesn't exist
Expand Down Expand Up @@ -368,5 +368,5 @@ def test_send_email_undefined_email(self):
with self.assertRaises(CourseEmail.DoesNotExist):
# we skip the call that updates subtask status, since we've not set up the InstructorTask
# for the subtask, and it's not important to the test.
with patch('bulk_email.tasks.update_subtask_status'):
with patch('lms.djangoapps.bulk_email.tasks.update_subtask_status'):
send_course_email(entry_id, bogus_email_id, to_list, global_email_context, subtask_status.to_dict())
2 changes: 1 addition & 1 deletion lms/djangoapps/bulk_email/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


@ddt.ddt
@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class CourseEmailTest(ModuleStoreTestCase):
"""Test the CourseEmail model."""

Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/bulk_email/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from xmodule.modulestore.tests.factories import CourseFactory


@patch('bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
@patch('lms.djangoapps.bulk_email.models.html_to_text', Mock(return_value='Mocking CourseEmail.text_message', autospec=True))
class TestOptoutCourseEmailsBySignal(ModuleStoreTestCase):
"""
Tests that the force_optout_all signal receiver opts the user out of course emails
Expand Down
Loading

0 comments on commit 4a120a9

Please sign in to comment.