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 = [ ...@@ -2289,7 +2289,7 @@ INSTALLED_APPS = [
'django_sites_extensions', 'django_sites_extensions',
# Email marketing integration # Email marketing integration
'email_marketing', 'email_marketing.apps.EmailMarketingConfig',
# additional release utilities to ease automation # additional release utilities to ease automation
'release_util', 'release_util',
......
...@@ -231,14 +231,7 @@ class TestUserPreferenceMiddleware(TestCase): ...@@ -231,14 +231,7 @@ class TestUserPreferenceMiddleware(TestCase):
# No preference yet, should write to the database # No preference yet, should write to the database
self.assertEqual(get_user_preference(self.user, LANGUAGE_KEY), None) self.assertEqual(get_user_preference(self.user, LANGUAGE_KEY), None)
self.middleware.process_request(self.request)
# 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') self.assertEqual(get_user_preference(self.user, LANGUAGE_KEY), 'es')
response = mock.Mock(spec=HttpResponse) response = mock.Mock(spec=HttpResponse)
...@@ -261,14 +254,7 @@ class TestUserPreferenceMiddleware(TestCase): ...@@ -261,14 +254,7 @@ class TestUserPreferenceMiddleware(TestCase):
# Cookie changed, should write to the database again # Cookie changed, should write to the database again
self.request.COOKIES[settings.LANGUAGE_COOKIE] = 'en' self.request.COOKIES[settings.LANGUAGE_COOKIE] = 'en'
self.middleware.process_request(self.request)
# 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') self.assertEqual(get_user_preference(self.user, LANGUAGE_KEY), 'en')
with self.assertNumQueries(1): 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