def __init__(self, parameters=None, on_open_callback=None): """Connection initialization expects an object that has implemented the Parameters class and a callback function to notify when we have successfully connected to the AMQP Broker. Available Parameters classes are the ConnectionParameters class and URLParameters class. :param pika.connection.Parameters parameters: Connection parameters :param on_open_callback: The method to call when the connection is open :type on_open_callback: method """ # Define our callback dictionary self.callbacks = callback.CallbackManager() # On connection callback if on_open_callback: self.add_on_open_callback(on_open_callback) # Set our configuration options self.params = parameters or ConnectionParameters() # Initialize the connection state and connect self._init_connection_state() self._connect()
def test_initialization(self): obj = callback.CallbackManager() self.assertDictEqual(obj._stack, {})
def setUp(self): self.obj = callback.CallbackManager() self.callback_mock = mock.Mock() self.mock_caller = mock.Mock()
def test_remove_with_no_callbacks_pending(self): self.obj = callback.CallbackManager() self.assertFalse(self.obj.remove(self.PREFIX, self.KEY, self.callback_mock))
def setUp(self): self.cm = callback.CallbackManager() self.test_cls = Mock(spec=['NAME']) self.test_cls.NAME = 'attr of self'