def test_do_not_send_email_and_do_activate(self):
     """
     Tests that when an inactive user logs-in using the social auth,
     an activation email is not sent.
     """
     pipeline_partial = {
         'kwargs': {
             'social': {
                 'uid': 'fake uid'
             }
         }
     }
     user = UserFactory(is_active=False)
     Registration().register(user)
     request = RequestFactory().get(settings.SOCIAL_AUTH_INACTIVE_USER_URL)
     request.user = user
     with patch('student.views.management.compose_and_send_activation_email') as email:
         with patch('third_party_auth.provider.Registry.get_from_pipeline') as reg:
             with patch('third_party_auth.pipeline.get', return_value=pipeline_partial):
                 with patch('third_party_auth.pipeline.running', return_value=True):
                     with patch('third_party_auth.is_enabled', return_value=True):
                         reg.skip_email_verification = True
                         inactive_user_view(request)
                         self.assertEquals(user.is_active, True)
                         self.assertEquals(email.called, False, msg='method should not have been called')
Exemple #2
0
 def test_do_not_send_email_and_do_activate(self):
     """
     Tests that when an inactive user logs-in using the social auth,
     an activation email is not sent.
     """
     pipeline_partial = {
         'kwargs': {
             'social': {
                 'uid': 'fake uid'
             }
         }
     }
     user = UserFactory(is_active=False)
     Registration().register(user)
     request = RequestFactory().get(settings.SOCIAL_AUTH_INACTIVE_USER_URL)
     request.user = user
     with patch('student.views.management.compose_and_send_activation_email') as email:
         with patch('third_party_auth.provider.Registry.get_from_pipeline') as reg:
             with patch('third_party_auth.pipeline.get', return_value=pipeline_partial):
                 with patch('third_party_auth.pipeline.running', return_value=True):
                     with patch('third_party_auth.is_enabled', return_value=True):
                         reg.skip_email_verification = True
                         inactive_user_view(request)
                         self.assertEquals(user.is_active, True)
                         self.assertEquals(email.called, False, msg='method should not have been called')
 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.
     """
     inactive_user = UserFactory(is_active=False)
     Registration().register(inactive_user)
     request = RequestFactory().get(settings.SOCIAL_AUTH_INACTIVE_USER_URL)
     request.user = inactive_user
     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)
             self.assertEqual(email.called, True, msg='method should have been called')
Exemple #4
0
 def test_send_email_to_inactive_user(self, mock_log):
     """
     Tests that when an inactive user logs-in using the social auth, system
     sends an activation email to the user.
     """
     inactive_user = UserFactory(is_active=False)
     Registration().register(inactive_user)
     request = RequestFactory().get(settings.SOCIAL_AUTH_INACTIVE_USER_URL)
     request.user = inactive_user
     with patch('edxmako.request_context.get_current_request'):
         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))
 def test_send_email_to_inactive_user(self, mock_log):
     """
     Tests that when an inactive user logs-in using the social auth, system
     sends an activation email to the user.
     """
     inactive_user = UserFactory(is_active=False)
     Registration().register(inactive_user)
     request = RequestFactory().get(settings.SOCIAL_AUTH_INACTIVE_USER_URL)
     request.user = inactive_user
     with patch('edxmako.request_context.get_current_request', return_value=request):
         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
             )
         )