|
|
f9af88c |
From e4149280e2e72e73985fdd7e040c833fc61a88a2 Mon Sep 17 00:00:00 2001
|
|
|
f9af88c |
From: Brian Bouterse <bmbouter@gmail.com>
|
|
|
f9af88c |
Date: Tue, 16 Feb 2016 14:56:23 -0500
|
|
|
f9af88c |
Subject: [PATCH] Updates Qpid transport with updated names of Qpid async
|
|
|
f9af88c |
interface
|
|
|
f9af88c |
|
|
|
f9af88c |
---
|
|
|
f9af88c |
kombu/tests/transport/test_qpid.py | 38 +++++++++++++++++++++++++++++---------
|
|
|
f9af88c |
kombu/transport/qpid.py | 16 +++++++++-------
|
|
|
f9af88c |
2 files changed, 38 insertions(+), 16 deletions(-)
|
|
|
f9af88c |
|
|
|
f9af88c |
diff --git a/kombu/tests/transport/test_qpid.py b/kombu/tests/transport/test_qpid.py
|
|
|
f9af88c |
index a3894e4..4340443 100644
|
|
|
f9af88c |
--- a/kombu/tests/transport/test_qpid.py
|
|
|
f9af88c |
+++ b/kombu/tests/transport/test_qpid.py
|
|
|
f9af88c |
@@ -1706,13 +1706,29 @@ def test_transport_establish_conn_uses_hostname_if_not_default(self):
|
|
|
f9af88c |
transport='tcp',
|
|
|
f9af88c |
)
|
|
|
f9af88c |
|
|
|
f9af88c |
- def test_transport_sets_qpid_message_received_handler(self):
|
|
|
f9af88c |
+ def test_transport_sets_qpid_message_ready_handler(self):
|
|
|
f9af88c |
self.transport.establish_connection()
|
|
|
f9af88c |
- qpid_conn = self.mock_conn.return_value.get_qpid_connection
|
|
|
f9af88c |
- new_mock_session = qpid_conn.return_value.session.return_value
|
|
|
f9af88c |
- mock_set_callback = new_mock_session.set_message_received_handler
|
|
|
f9af88c |
- expected_callback = self.transport._qpid_session_ready
|
|
|
f9af88c |
- mock_set_callback.assert_called_once_with(expected_callback)
|
|
|
f9af88c |
+ qpid_conn_call = self.mock_conn.return_value.get_qpid_connection
|
|
|
f9af88c |
+ mock_session = qpid_conn_call.return_value.session.return_value
|
|
|
f9af88c |
+ mock_set_callback = mock_session.set_message_received_notify_handler
|
|
|
f9af88c |
+ expected_msg_callback = self.transport._qpid_message_ready_handler
|
|
|
f9af88c |
+ mock_set_callback.assert_called_once_with(expected_msg_callback)
|
|
|
f9af88c |
+
|
|
|
f9af88c |
+ def test_transport_sets_session_exception_handler(self):
|
|
|
f9af88c |
+ self.transport.establish_connection()
|
|
|
f9af88c |
+ qpid_conn_call = self.mock_conn.return_value.get_qpid_connection
|
|
|
f9af88c |
+ mock_session = qpid_conn_call.return_value.session.return_value
|
|
|
f9af88c |
+ mock_set_callback = mock_session.set_async_exception_notify_handler
|
|
|
f9af88c |
+ exc_callback = self.transport._qpid_async_exception_notify_handler
|
|
|
f9af88c |
+ mock_set_callback.assert_called_once_with(exc_callback)
|
|
|
f9af88c |
+
|
|
|
f9af88c |
+ def test_transport_sets_connection_exception_handler(self):
|
|
|
f9af88c |
+ self.transport.establish_connection()
|
|
|
f9af88c |
+ qpid_conn_call = self.mock_conn.return_value.get_qpid_connection
|
|
|
f9af88c |
+ qpid_conn = qpid_conn_call.return_value
|
|
|
f9af88c |
+ mock_set_callback = qpid_conn.set_async_exception_notify_handler
|
|
|
f9af88c |
+ exc_callback = self.transport._qpid_async_exception_notify_handler
|
|
|
f9af88c |
+ mock_set_callback.assert_called_once_with(exc_callback)
|
|
|
f9af88c |
|
|
|
f9af88c |
|
|
|
f9af88c |
@case_no_python3
|
|
|
f9af88c |
@@ -1766,7 +1782,7 @@ def test_transport_register_with_event_loop_calls_add_reader(self):
|
|
|
f9af88c |
@case_no_python3
|
|
|
f9af88c |
@case_no_pypy
|
|
|
f9af88c |
@disable_runtime_dependency_check
|
|
|
f9af88c |
-class TestTransportQpidSessionReady(Case):
|
|
|
f9af88c |
+class TestTransportQpidCallbackHandlers(Case):
|
|
|
f9af88c |
|
|
|
f9af88c |
def setUp(self):
|
|
|
f9af88c |
self.patch_a = patch(QPID_MODULE + '.os.write')
|
|
|
f9af88c |
@@ -1776,10 +1792,14 @@ def setUp(self):
|
|
|
f9af88c |
def tearDown(self):
|
|
|
f9af88c |
self.patch_a.stop()
|
|
|
f9af88c |
|
|
|
f9af88c |
- def test_transport__qpid_session_ready_writes_symbol_to_fd(self):
|
|
|
f9af88c |
- self.transport._qpid_session_ready()
|
|
|
f9af88c |
+ def test__qpid_message_ready_handler_writes_symbol_to_fd(self):
|
|
|
f9af88c |
+ self.transport._qpid_message_ready_handler(Mock())
|
|
|
f9af88c |
self.mock_os_write.assert_called_once_with(self.transport._w, '0')
|
|
|
f9af88c |
|
|
|
f9af88c |
+ def test__qpid_async_exception_notify_handler_writes_symbol_to_fd(self):
|
|
|
f9af88c |
+ self.transport._qpid_async_exception_notify_handler(Mock(), Mock())
|
|
|
f9af88c |
+ self.mock_os_write.assert_called_once_with(self.transport._w, 'e')
|
|
|
f9af88c |
+
|
|
|
f9af88c |
|
|
|
f9af88c |
@case_no_python3
|
|
|
f9af88c |
@case_no_pypy
|
|
|
f9af88c |
diff --git a/kombu/transport/qpid.py b/kombu/transport/qpid.py
|
|
|
f9af88c |
index 081c6c6..55cafdd 100644
|
|
|
f9af88c |
--- a/kombu/transport/qpid.py
|
|
|
f9af88c |
+++ b/kombu/transport/qpid.py
|
|
|
f9af88c |
@@ -1434,10 +1434,10 @@ def verify_runtime_environment(self):
|
|
|
f9af88c |
'with your package manager. You can also try `pip install '
|
|
|
f9af88c |
'qpid-python`.')
|
|
|
f9af88c |
|
|
|
f9af88c |
- def _qpid_session_ready(self):
|
|
|
f9af88c |
+ def _qpid_message_ready_handler(self, session):
|
|
|
f9af88c |
os.write(self._w, '0')
|
|
|
f9af88c |
|
|
|
f9af88c |
- def _qpid_exception(self, obj_with_exception):
|
|
|
f9af88c |
+ def _qpid_async_exception_notify_handler(self, obj_with_exception, exc):
|
|
|
f9af88c |
os.write(self._w, 'e')
|
|
|
f9af88c |
|
|
|
f9af88c |
def on_readable(self, connection, loop):
|
|
|
f9af88c |
@@ -1596,12 +1596,14 @@ def establish_connection(self):
|
|
|
f9af88c |
conn = self.Connection(**opts)
|
|
|
f9af88c |
conn.client = self.client
|
|
|
f9af88c |
self.session = conn.get_qpid_connection().session()
|
|
|
f9af88c |
- self.session.set_message_received_handler(self._qpid_session_ready)
|
|
|
f9af88c |
- conn.get_qpid_connection().set_exception_notify_handler(
|
|
|
f9af88c |
- self._qpid_exception
|
|
|
f9af88c |
+ self.session.set_message_received_notify_handler(
|
|
|
f9af88c |
+ self._qpid_message_ready_handler
|
|
|
f9af88c |
)
|
|
|
f9af88c |
- self.session.set_exception_notify_handler(
|
|
|
f9af88c |
- self._qpid_exception
|
|
|
f9af88c |
+ conn.get_qpid_connection().set_async_exception_notify_handler(
|
|
|
f9af88c |
+ self._qpid_async_exception_notify_handler
|
|
|
f9af88c |
+ )
|
|
|
f9af88c |
+ self.session.set_async_exception_notify_handler(
|
|
|
f9af88c |
+ self._qpid_async_exception_notify_handler
|
|
|
f9af88c |
)
|
|
|
f9af88c |
return conn
|
|
|
f9af88c |
|