Merge pull request #17050 from edx/tasawer/learner-3649/exclude-enterprise-learners-from-the-welcome-email
Exclude enterprise learners from the welcome email
This commit is contained in:
@@ -96,7 +96,9 @@ def update_user(self, sailthru_vars, email, site=None, new_user=False, activatio
|
||||
return
|
||||
|
||||
# if activating user, send welcome email
|
||||
if activation and email_config.sailthru_welcome_template and is_default_site(site):
|
||||
if activation and email_config.sailthru_welcome_template and is_default_site(site) and not \
|
||||
sailthru_vars.get('is_enterprise_learner'):
|
||||
|
||||
scheduled_datetime = datetime.utcnow() + timedelta(seconds=email_config.welcome_email_send_delay)
|
||||
try:
|
||||
sailthru_response = sailthru_client.api_post(
|
||||
|
||||
@@ -212,6 +212,21 @@ class EmailMarketingTests(TestCase):
|
||||
self.assertFalse(mock_log_error.called)
|
||||
self.assertNotEqual(mock_sailthru_post.call_args[0][0], "send")
|
||||
|
||||
@patch('email_marketing.tasks.SailthruClient.api_post')
|
||||
def test_email_not_sent_to_enterprise_learners(self, mock_sailthru_post):
|
||||
"""
|
||||
tests that welcome email is not sent to the enterprise learner
|
||||
"""
|
||||
mock_sailthru_post.return_value = SailthruResponse(JsonResponse({'ok': True}))
|
||||
update_user.delay(
|
||||
sailthru_vars={
|
||||
'is_enterprise_learner': True,
|
||||
'enterprise_name': 'test name',
|
||||
},
|
||||
email=self.user.email
|
||||
)
|
||||
self.assertNotEqual(mock_sailthru_post.call_args[0][0], "send")
|
||||
|
||||
@patch('email_marketing.tasks.SailthruClient.api_post')
|
||||
@patch('email_marketing.tasks.SailthruClient.api_get')
|
||||
def test_add_user_list_existing_domain(self, mock_sailthru_get, mock_sailthru_post):
|
||||
|
||||
Reference in New Issue
Block a user