'Test email was sent if no errors encountered.'

@patch('django.core.mail.send_mail')
@patch('student.views.render_to_string', Mock(side_effect=mock_render_to_string, autospec=True))
def test_email_success(self, send_mail):

    old_email = self.user.email
    new_email = 'valid@example.com'
    registration_key = 'test    registration    key'
    self.assertIsNone(self.do_email_change(self.user, new_email, registration_key))
    context = {'key': registration_key, 'old_email': old_email, 'new_email': new_email}
    send_mail.assert_called_with(mock_render_to_string('emails/email_change_subject.txt', context), mock_render_to_string('emails/email_change.txt', context), configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL), [new_email])
    self.assert_event_emitted(SETTING_CHANGE_INITIATED, user_id=self.user.id, setting=u'email', old=old_email, new=new_email)
