Commit 7b4a3c17 by John Eskew

Move email_marketing startup.py to AppConfig::ready().

Remove query counting of LMS signals.
parent b02c7447
"""
Configuration for the email_marketing Django application.
"""
from django.apps import AppConfig
class EmailMarketingConfig(AppConfig):
"""
Configuration class for the email_marketing Django application.
"""
name = 'email_marketing'
verbose_name = "Email Marketing"
def ready(self):
# Register the signal handlers.
from . import signals # pylint: disable=unused-import
""" email_marketing app. """
# this is here to support registering the signals in signals.py
from email_marketing import signals # pylint: disable=unused-import
......@@ -2289,7 +2289,7 @@ INSTALLED_APPS = [
'django_sites_extensions',
# Email marketing integration
'email_marketing',
'email_marketing.apps.EmailMarketingConfig',
# additional release utilities to ease automation
'release_util',
......
......@@ -231,14 +231,7 @@ class TestUserPreferenceMiddleware(TestCase):
# No preference yet, should write to the database
self.assertEqual(get_user_preference(self.user, LANGUAGE_KEY), None)
# The 'email_marketing' app is installed in the LMS env but not the CMS env. It listens for the
# USER_FIELD_CHANGED signal (utils.model_utils) and does a query to check the EmailMarketingConfiguration
# table to see if Sailthru integreation is enabled.
expected_queries = 6 if 'email_marketing' in settings.INSTALLED_APPS else 5
with self.assertNumQueries(expected_queries):
self.middleware.process_request(self.request)
self.assertEqual(get_user_preference(self.user, LANGUAGE_KEY), 'es')
response = mock.Mock(spec=HttpResponse)
......@@ -261,14 +254,7 @@ class TestUserPreferenceMiddleware(TestCase):
# Cookie changed, should write to the database again
self.request.COOKIES[settings.LANGUAGE_COOKIE] = 'en'
# The 'email_marketing' app is installed in the LMS env but not the CMS env. It listens for the
# USER_FIELD_CHANGED signal (utils.model_utils) and does a query to check the EmailMarketingConfiguration
# table to see if Sailthru integreation is enabled.
expected_queries = 6 if 'email_marketing' in settings.INSTALLED_APPS else 5
with self.assertNumQueries(expected_queries):
self.middleware.process_request(self.request)
self.assertEqual(get_user_preference(self.user, LANGUAGE_KEY), 'en')
with self.assertNumQueries(1):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment