From bb4b38b30b61f66605f4fcadeba2ee1101d1560c Mon Sep 17 00:00:00 2001 From: Awais Jibran Date: Wed, 18 Mar 2020 20:43:20 +0500 Subject: [PATCH] Do not log after sending activation email --- common/djangoapps/student/tasks.py | 5 ----- common/djangoapps/student/tests/test_email.py | 10 +++------- common/djangoapps/student/tests/test_tasks.py | 1 - 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/common/djangoapps/student/tasks.py b/common/djangoapps/student/tasks.py index 022cbf417c..56a7565ab5 100644 --- a/common/djangoapps/student/tasks.py +++ b/common/djangoapps/student/tasks.py @@ -43,10 +43,6 @@ def send_activation_email(self, msg_string, from_address=None): try: with emulate_http_request(site=site, user=user): ace.send(msg) - # Log that the Activation Email has been sent to user without an exception - log.info("Activation Email has been sent to User {user_email}".format( - user_email=dest_addr - )) except RecoverableChannelDeliveryError: log.info('Retrying sending email to user {dest_addr}, attempt # {attempt} of {max_attempts}'.format( dest_addr=dest_addr, @@ -67,6 +63,5 @@ def send_activation_email(self, msg_string, from_address=None): 'Unable to send activation email to user from "%s" to "%s"', from_address, dest_addr, - exc_info=True ) raise Exception diff --git a/common/djangoapps/student/tests/test_email.py b/common/djangoapps/student/tests/test_email.py index 42b03af0fe..a184184a85 100644 --- a/common/djangoapps/student/tests/test_email.py +++ b/common/djangoapps/student/tests/test_email.py @@ -199,8 +199,8 @@ class ActivationEmailTests(EmailTemplateTagMixin, CacheIsolationTestCase): self.assertEqual(user.is_active, True) self.assertEqual(email.called, False, msg='method should not have been called') - @patch('student.tasks.log') - def test_send_email_to_inactive_user(self, mock_log): + @patch('student.views.management.compose_activation_email') + def test_send_email_to_inactive_user(self, email): """ Tests that when an inactive user logs-in using the social auth, system sends an activation email to the user. @@ -212,11 +212,7 @@ class ActivationEmailTests(EmailTemplateTagMixin, CacheIsolationTestCase): with patch('edxmako.request_context.get_current_request', return_value=request): with patch('third_party_auth.pipeline.running', return_value=False): inactive_user_view(request) - mock_log.info.assert_called_with( - "Activation Email has been sent to User {user_email}".format( - user_email=inactive_user.email - ) - ) + self.assertEqual(email.called, True, msg='method should have been called') @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS") diff --git a/common/djangoapps/student/tests/test_tasks.py b/common/djangoapps/student/tests/test_tasks.py index 68946c8025..06ab5893af 100644 --- a/common/djangoapps/student/tests/test_tasks.py +++ b/common/djangoapps/student/tests/test_tasks.py @@ -85,7 +85,6 @@ class SendActivationEmailTestCase(TestCase): 'Unable to send activation email to user from "%s" to "%s"', from_address, self.student.email, - exc_info=True ) # Assert that nothing else was logged