Exemplo n.º 1
0
    def test_email_enabled(self, mock_smtp, mock_getbool):
        mail.handle_event(self.notifier_config, self.event)

        # verify
        self.assertEqual(mock_smtp.call_count, 2)
        mock_sendmail = mock_smtp.return_value.sendmail
        self.assertEqual(mock_sendmail.call_args[0][0],
                         config.get('email', 'from'))
        self.assertTrue(mock_sendmail.call_args[0][1] in self.notifier_config['addresses'])

        # verify message attributes
        message = Parser().parsestr(mock_sendmail.call_args[0][2])
        self.assertEqual(json.loads(message.get_payload()), self.event.payload)
        self.assertEqual(message.get('Subject', None), self.notifier_config['subject'])
        self.assertEqual(message.get('From', None), config.get('email', 'from'))
        self.assertTrue(message.get('To', None) in self.notifier_config['addresses'])
Exemplo n.º 2
0
    def test_email_enabled(self, mock_smtp, mock_getbool):
        mail.handle_event(self.notifier_config, self.event)

        #verify
        self.assertEqual(mock_smtp.call_count, 2)
        mock_sendmail = mock_smtp.return_value.sendmail
        self.assertEqual(mock_sendmail.call_args[0][0],
            config.get('email', 'from'))
        self.assertTrue(mock_sendmail.call_args[0][1] in self.notifier_config['addresses'])

        # verify message attributes
        message = Parser().parsestr(mock_sendmail.call_args[0][2])
        self.assertEqual(json.loads(message.get_payload()), self.event.payload)
        self.assertEqual(message.get('Subject', None), self.notifier_config['subject'])
        self.assertEqual(message.get('From', None), config.get('email', 'from'))
        self.assertTrue(message.get('To', None) in self.notifier_config['addresses'])
Exemplo n.º 3
0
 def test_email_disabled(self, mock_smtp, mock_getbool):
     mail.handle_event(self.notifier_config, self.event)
     self.assertFalse(mock_smtp.called)
Exemplo n.º 4
0
 def test_email_disabled(self, mock_smtp, mock_getbool):
     mail.handle_event(self.notifier_config, self.event)
     self.assertFalse(mock_smtp.called)
Exemplo n.º 5
0
 def test_email_serialize_objid(self, mock_smtp, mock_getbool, mock_task_ser):
     event_with_id = data.Event('test-1', {'foo': _test_objid()})
     mock_task_ser.return_value = 'serialized task'
     # no TypeError = success
     mail.handle_event(self.notifier_config, event_with_id)
Exemplo n.º 6
0
 def test_email_serialize_objid(self, mock_smtp, mock_getbool):
     event_with_id = data.Event('test-1', {'foo': _test_objid()})
     # no TypeError = success
     mail.handle_event(self.notifier_config, event_with_id)
Exemplo n.º 7
0
 def test_email_serialize_objid(self, mock_smtp, mock_getbool):
     event_with_id = Event('test-1', {'foo': _test_objid()})
     # no TypeError = success
     mail.handle_event(self.notifier_config, event_with_id)