def test_cast_to_server_uses_server_params(self): """Test kombu rpc.cast""" ctxt = rpc_common.CommonRpcContext(user='******', project='fake_project') server_params = {'username': '******', 'password': '******', 'hostname': 'fake_hostname', 'port': 31337, 'virtual_host': 'fake_virtual_host'} class MyConnection(impl_kombu.Connection): def __init__(myself, *args, **kwargs): super(MyConnection, myself).__init__(*args, **kwargs) self.assertEqual( myself.params_list, [{'hostname': server_params['hostname'], 'userid': server_params['username'], 'password': server_params['password'], 'port': server_params['port'], 'virtual_host': server_params['virtual_host'], 'transport': 'memory'}]) def topic_send(_context, topic, msg): pass MyConnection.pool = rpc_amqp.Pool(FLAGS, MyConnection) self.stubs.Set(impl_kombu, 'Connection', MyConnection) impl_kombu.cast_to_server(FLAGS, ctxt, server_params, 'fake_topic', {'msg': 'fake'})
def test_cast_interface_uses_default_options(self): """Test kombu rpc.cast""" ctxt = rpc_common.CommonRpcContext(user='******', project='fake_project') class MyConnection(impl_kombu.Connection): def __init__(myself, *args, **kwargs): super(MyConnection, myself).__init__(*args, **kwargs) self.assertEqual( myself.params_list, [{'hostname': FLAGS.rabbit_host, 'userid': FLAGS.rabbit_userid, 'password': FLAGS.rabbit_password, 'port': FLAGS.rabbit_port, 'virtual_host': FLAGS.rabbit_virtual_host, 'transport': 'memory'}]) def topic_send(_context, topic, msg): pass MyConnection.pool = rpc_amqp.Pool(FLAGS, MyConnection) self.stubs.Set(impl_kombu, 'Connection', MyConnection) impl_kombu.cast(FLAGS, ctxt, 'fake_topic', {'msg': 'fake'})
def setUp(self, supports_timeouts=True, topic='test', topic_nested='nested'): super(BaseRpcTestCase, self).setUp() self.topic = topic or self.topic self.topic_nested = topic_nested or self.topic_nested self.supports_timeouts = supports_timeouts self.context = rpc_common.CommonRpcContext(user='******', pw='fake_pw') if self.rpc: receiver = TestReceiver() self.conn = self._create_consumer(receiver, self.topic)
def setUp(self, supports_timeouts=True, topic='test', topic_nested='nested'): super(BaseRpcTestCase, self).setUp() self.topic = topic or self.topic self.topic_nested = topic_nested or self.topic_nested self.supports_timeouts = supports_timeouts self.context = rpc_common.CommonRpcContext(user='******', pw='fake_pw') self.FLAGS = self.useFixture(config.Config()).conf if self.rpc: receiver = TestReceiver() self.conn = self._create_consumer(receiver, self.topic) self.addCleanup(self.conn.close)