示例#1
0
 def test_with_admins(self, mocked_send):
     self.app.config['ADMINS'] = [
         ('Admin', '*****@*****.**'),
     ]
     mailerrors.init_app(self.app)
     self.test_client.get('/error')
     self.assertEqual(mocked_send.call_count, 1)
     msg = mocked_send.call_args[0][0]
     self.assertEqual(msg.subject, 'Error in Flask app')
     self.assertTrue('Error Message' in msg.body)
     self.assertEqual(msg.recipients, ['*****@*****.**'])
     self.test_client.get('/exception')
     self.assertEqual(mocked_send.call_count, 2)
     msg = mocked_send.call_args[0][0]
     self.assertTrue('Exceptional Message' in msg.body)
示例#2
0
 def test_with_admins(self, mocked_send):
     self.app.config['ADMINS'] = [
         ('Admin', '*****@*****.**'),
     ]
     mailerrors.init_app(self.app)
     self.test_client.get('/error')
     self.assertEqual(mocked_send.call_count, 1)
     msg = mocked_send.call_args[0][0]
     self.assertEqual(msg.subject, 'Error in Flask app')
     self.assertTrue('Error Message' in msg.body)
     self.assertEqual(msg.recipients, ['*****@*****.**'])
     self.test_client.get('/exception')
     self.assertEqual(mocked_send.call_count, 2)
     msg = mocked_send.call_args[0][0]
     self.assertTrue('Exceptional Message' in msg.body)
示例#3
0
 def test_double_init(self):
     handlers_before_init = len(self.app.logger.handlers)
     mailerrors.init_app(self.app)
     mailerrors.init_app(self.app)
     handlers_after_init = len(self.app.logger.handlers)
     self.assertEqual(handlers_before_init + 1, handlers_after_init)
示例#4
0
 def test_without_admins(self, mocked_send):
     mailerrors.init_app(self.app)
     self.app.logger.error('test without ADMINS')
     self.assertFalse(mocked_send.called)
示例#5
0
 def test_double_init(self):
     handlers_before_init = len(self.app.logger.handlers)
     mailerrors.init_app(self.app)
     mailerrors.init_app(self.app)
     handlers_after_init = len(self.app.logger.handlers)
     self.assertEqual(handlers_before_init + 1, handlers_after_init)
示例#6
0
 def test_without_admins(self, mocked_send):
     mailerrors.init_app(self.app)
     self.app.logger.error('test without ADMINS')
     self.assertFalse(mocked_send.called)