def test_cli_webserver_shutdown_when_gunicorn_master_is_killed(self, _):
     # Shorten timeout so that this test doesn't take too long time
     args = self.parser.parse_args(['webserver'])
     with conf_vars({('webserver', 'web_server_master_timeout'): '10'}):
         with self.assertRaises(SystemExit) as e:
             webserver_command.webserver(args)
     self.assertEqual(e.exception.code, 1)
Beispiel #2
0
 def test_send_mime_ssl(self, mock_smtp, mock_smtp_ssl):
     mock_smtp.return_value = mock.Mock()
     mock_smtp_ssl.return_value = mock.Mock()
     with conf_vars({('smtp', 'smtp_ssl'): 'True'}):
         utils.email.send_MIME_email('from',
                                     'to',
                                     MIMEMultipart(),
                                     dryrun=False)
     self.assertFalse(mock_smtp.called)
     mock_smtp_ssl.assert_called_once_with(
         conf.get('smtp', 'SMTP_HOST'),
         conf.getint('smtp', 'SMTP_PORT'),
     )
Beispiel #3
0
 def test_custom_backend(self, mock_send_email):
     with conf_vars({
         ('email', 'email_backend'):
             'tests.utils.test_email.send_email_test'
     }):
         utils.email.send_email('to', 'subject', 'content')
     send_email_test.assert_called_once_with('to',
                                             'subject',
                                             'content',
                                             files=None,
                                             dryrun=False,
                                             cc=None,
                                             bcc=None,
                                             mime_charset='utf-8',
                                             mime_subtype='mixed')
     self.assertFalse(mock_send_email.called)
Beispiel #4
0
 def test_send_mime_noauth(self, mock_smtp, mock_smtp_ssl):
     mock_smtp.return_value = mock.Mock()
     mock_smtp_ssl.return_value = mock.Mock()
     with conf_vars({
         ('smtp', 'smtp_user'): None,
         ('smtp', 'smtp_password'): None,
     }):
         utils.email.send_MIME_email('from',
                                     'to',
                                     MIMEMultipart(),
                                     dryrun=False)
     self.assertFalse(mock_smtp_ssl.called)
     mock_smtp.assert_called_once_with(
         conf.get('smtp', 'SMTP_HOST'),
         conf.getint('smtp', 'SMTP_PORT'),
     )
     self.assertFalse(mock_smtp.login.called)