def test_queue_email_failure(self): logger = logging.getLogger("cms_user_tasks.signals") hdlr = MockLoggingHandler(level="DEBUG") logger.addHandler(hdlr) with mock.patch('cms_user_tasks.tasks.send_task_complete_email.delay') as mock_delay: mock_delay.side_effect = NoAuthHandlerFound() user_task_stopped.send(sender=UserTaskStatus, status=self.status) self.assertTrue(mock_delay.called) self.assertEqual(hdlr.messages['error'][0], u'Unable to queue send_task_complete_email')
def test_email_retries(self): """ Make sure we can succeed on retries """ with mock.patch('django.core.mail.send_mail') as mock_exception: mock_exception.side_effect = NoAuthHandlerFound() with mock.patch('cms_user_tasks.tasks.send_task_complete_email.retry') as mock_retry: user_task_stopped.send(sender=UserTaskStatus, status=self.status) self.assertTrue(mock_retry.called)
def test_missing_auth(self, mock_iam): mock_iam.side_effect = NoAuthHandlerFound('bad') with self.assertRaises(exceptions.InvalidCredentials): base.AWSBaseActor('Unit Test Action', {'region': 'fail'})