'Ensure that error returned from Sailthru api is logged'

@patch('email_marketing.tasks.log.error')
@patch('email_marketing.tasks.SailthruClient.api_post')
def test_update_user_error_logging(self, mock_sailthru, mock_log_error):

    mock_sailthru.return_value = SailthruResponse(JsonResponse({'error': 100, 'errormsg': 'Got    an    error'}))
    update_user.delay({}, self.user.email)
    self.assertTrue(mock_log_error.called)
    mock_log_error.reset_mock()
    mock_sailthru.side_effect = SailthruClientError
    update_user.delay({}, self.user.email, self.site_domain)
    self.assertTrue(mock_log_error.called)
    mock_log_error.reset_mock()
    mock_sailthru.side_effect = [SailthruResponse(JsonResponse({'ok': True})), SailthruClientError]
    update_user.delay({}, self.user.email, new_user=True)
    self.assertTrue(mock_log_error.called)
    mock_log_error.reset_mock()
    mock_sailthru.side_effect = [SailthruResponse(JsonResponse({'ok': True})), SailthruResponse(JsonResponse({'error': 100, 'errormsg': 'Got    an    error'}))]
    update_user.delay({}, self.user.email, new_user=True)
    self.assertTrue(mock_log_error.called)
