本文整理汇总了Python中pyon.net.channel.BaseChannel类的典型用法代码示例。如果您正苦于以下问题:Python BaseChannel类的具体用法?Python BaseChannel怎么用?Python BaseChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_on_channel_close
def test_on_channel_close(self):
ch = BaseChannel()
ch.on_channel_open(Mock())
ch._transport.channel_number = 1
ch.on_channel_close(ch, 0, 'hi')
self.assertIsNone(ch._transport)
示例2: test_on_channel_close
def test_on_channel_close(self):
ch = BaseChannel()
ch._amq_chan = Mock()
ch._amq_chan.channel_number = 1
ch.on_channel_close(0, 'hi')
self.assertIsNone(ch._amq_chan)
示例3: test_get_channel_id
def test_get_channel_id(self):
ch = BaseChannel()
self.assertTrue(ch.get_channel_id() is None)
ch._amq_chan = Mock()
self.assertEquals(ch.get_channel_id(), ch._amq_chan.channel_number)
示例4: test_get_channel_id
def test_get_channel_id(self):
ch = BaseChannel()
self.assertTrue(ch.get_channel_id() is None)
ch.on_channel_open(Mock())
self.assertEquals(ch.get_channel_id(), ch._transport.channel_number)
示例5: test__sync_call_no_ret_value
def test__sync_call_no_ret_value(self):
def async_func(*args, **kwargs):
cbparam = kwargs.get("callback")
cbparam()
ch = BaseChannel()
rv = ch._sync_call(async_func, "callback")
self.assertIsNone(rv)
示例6: test__sync_call_with_normal_and_kwarg_rets
def test__sync_call_with_normal_and_kwarg_rets(self):
def async_func(*args, **kwargs):
cbparam = kwargs.get('callback')
cbparam(sentinel.arg, sup=sentinel.val, sup2=sentinel.val2)
ch = BaseChannel()
rv = ch._sync_call(async_func, 'callback')
self.assertEquals(rv, (sentinel.arg, {'sup':sentinel.val, 'sup2':sentinel.val2}))
示例7: test_on_channel_open
def test_on_channel_open(self):
ch = BaseChannel()
transport = Mock()
ch.on_channel_open(transport)
transport.add_on_close_callback.assert_called_once_with(ch.on_channel_close)
self.assertEquals(ch._transport, transport)
示例8: test_close_with_callback
def test_close_with_callback(self):
# with close callback
cbmock = Mock()
ch = BaseChannel(close_callback=cbmock)
ch._fsm.current_state = ch.S_ACTIVE
ch.close()
cbmock.assert_called_once_with(ch)
示例9: test__sync_call_with_kwarg_rets
def test__sync_call_with_kwarg_rets(self):
def async_func(*args, **kwargs):
cbparam = kwargs.get("callback")
cbparam(sup=sentinel.val, sup2=sentinel.val2)
ch = BaseChannel()
rv = ch._sync_call(async_func, "callback")
self.assertEquals(rv, {"sup": sentinel.val, "sup2": sentinel.val2})
示例10: test__sync_call_with_ret_value
def test__sync_call_with_ret_value(self):
def async_func(*args, **kwargs):
cbparam = kwargs.get("callback")
cbparam(sentinel.val)
ch = BaseChannel()
rv = ch._sync_call(async_func, "callback")
self.assertEquals(rv, sentinel.val)
示例11: test_on_channel_open
def test_on_channel_open(self):
ch = BaseChannel()
ac = Mock(pchannel.Channel)
ch.on_channel_open(ac)
ac.add_on_close_callback.assert_called_once_with(ch.on_channel_close)
self.assertEquals(ch._amq_chan, ac)
示例12: test__sync_call_with_mult_rets
def test__sync_call_with_mult_rets(self):
def async_func(*args, **kwargs):
cbparam = kwargs.get('callback')
cbparam(sentinel.val, sentinel.val2)
ch = BaseChannel()
rv = ch._sync_call(async_func, 'callback')
self.assertEquals(rv, (sentinel.val, sentinel.val2))
示例13: test_close
def test_close(self):
# without close callback
transport = Mock()
ch = BaseChannel()
ch.on_channel_open(transport)
ch._fsm.current_state = ch.S_ACTIVE
ch.close()
transport.close.assert_called_once_with()
示例14: test_close
def test_close(self):
# without close callback
ac = Mock() #pchannel.Channel) # cannot use this because callbacks is populated dynamically
ch = BaseChannel()
ch._amq_chan = ac
ch._fsm.current_state = ch.S_ACTIVE
ch.close()
ac.close.assert_called_once_with()
self.assertEquals(ac.callbacks.remove.call_count, 4)
示例15: test_declare_exchange_point
def test_declare_exchange_point(self):
# make sure no xp param results in assertion
ch = BaseChannel()
self.assertRaises(AssertionError, ch._declare_exchange, None)
transport = Mock()
ch.on_channel_open(transport)
ch._declare_exchange('hello')
self.assertTrue(transport.declare_exchange_impl.called)
self.assertIn('hello', transport.declare_exchange_impl.call_args[0])
self.assertIn('exchange_type', transport.declare_exchange_impl.call_args[1])
self.assertIn('durable', transport.declare_exchange_impl.call_args[1])
self.assertIn('auto_delete', transport.declare_exchange_impl.call_args[1])