Ejemplo n.º 1
0
    def test_clear_messages_on_send(self):
        """Assert the message queue is cleared after the event handler runs."""
        session = Session()
        session.info['messages'] = [api.Message()]

        with fml_testing.mock_sends(api.Message()):
            notifications.send_messages_after_commit(session)

        assert session.info['messages'] == []
Ejemplo n.º 2
0
    def test_error_logged(self, mock_log, mock_pub):
        session = Session()
        message = api.Message()
        session.info['messages'] = [message]
        mock_pub.side_effect = fml_exceptions.BaseException()

        notifications.send_messages_after_commit(session)

        mock_log.exception.assert_called_once_with(
            "An error occurred publishing %r after a database commit", message)
Ejemplo n.º 3
0
 def test_no_messages(self):
     """Assert if no messages have been queued, the event handler succeeds."""
     with fml_testing.mock_sends():
         notifications.send_messages_after_commit(Session())