disabled activation email
This commit is contained in:
@@ -150,6 +150,32 @@ class ActivationEmailTests(CacheIsolationTestCase):
|
||||
for fragment in body_fragments:
|
||||
self.assertIn(fragment, msg.body)
|
||||
|
||||
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')
|
||||
|
||||
@patch('student.tasks.log')
|
||||
def test_send_email_to_inactive_user(self, mock_log):
|
||||
"""
|
||||
@@ -161,12 +187,13 @@ class ActivationEmailTests(CacheIsolationTestCase):
|
||||
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
|
||||
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
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@patch('student.views.login.render_to_string', Mock(side_effect=mock_render_to_string, autospec=True))
|
||||
|
||||
Reference in New Issue
Block a user