• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python channel.BaseChannel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyon.net.channel.BaseChannel的典型用法代码示例。如果您正苦于以下问题:Python BaseChannel类的具体用法?Python BaseChannel怎么用?Python BaseChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了BaseChannel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:ooici,项目名称:pyon,代码行数:7,代码来源:test_channel.py


示例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)
开发者ID:swarbhanu,项目名称:pyon,代码行数:7,代码来源:test_channel.py


示例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)
开发者ID:swarbhanu,项目名称:pyon,代码行数:7,代码来源:test_channel.py


示例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)
开发者ID:ooici,项目名称:pyon,代码行数:7,代码来源:test_channel.py


示例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)
开发者ID:oldpatricka,项目名称:pyon,代码行数:8,代码来源:test_channel.py


示例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}))
开发者ID:swarbhanu,项目名称:pyon,代码行数:8,代码来源:test_channel.py


示例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)
开发者ID:ooici,项目名称:pyon,代码行数:8,代码来源:test_channel.py


示例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)
开发者ID:ooici,项目名称:pyon,代码行数:8,代码来源:test_channel.py


示例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})
开发者ID:oldpatricka,项目名称:pyon,代码行数:8,代码来源:test_channel.py


示例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)
开发者ID:oldpatricka,项目名称:pyon,代码行数:8,代码来源:test_channel.py


示例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)
开发者ID:swarbhanu,项目名称:pyon,代码行数:8,代码来源:test_channel.py


示例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))
开发者ID:swarbhanu,项目名称:pyon,代码行数:8,代码来源:test_channel.py


示例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()
开发者ID:ooici,项目名称:pyon,代码行数:10,代码来源:test_channel.py


示例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)
开发者ID:swarbhanu,项目名称:pyon,代码行数:11,代码来源:test_channel.py


示例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])
开发者ID:ooici,项目名称:pyon,代码行数:14,代码来源:test_channel.py


示例16: 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)

        ch._transport = Mock()
        ch._amq_chan = Mock()

        ch._declare_exchange("hello")
        self.assertTrue(ch._transport.declare_exchange_impl.called)
        self.assertIn(ch._amq_chan, ch._transport.declare_exchange_impl.call_args[0])
        self.assertIn("hello", ch._transport.declare_exchange_impl.call_args[0])
        self.assertIn("exchange_type", ch._transport.declare_exchange_impl.call_args[1])
        self.assertIn("durable", ch._transport.declare_exchange_impl.call_args[1])
        self.assertIn("auto_delete", ch._transport.declare_exchange_impl.call_args[1])
开发者ID:oldpatricka,项目名称:pyon,代码行数:15,代码来源:test_channel.py


示例17: test_on_channel_closed_with_error_callback

    def test_on_channel_closed_with_error_callback(self):
        ch = BaseChannel()
        ch.on_channel_open(Mock())
        ch._transport.channel_number = 1

        closemock = Mock()
        ch.set_closed_error_callback(closemock)

        ch.on_channel_close(ch, 1, 'hi')

        closemock.assert_called_once_with(ch, 1, 'hi')
开发者ID:ooici,项目名称:pyon,代码行数:11,代码来源:test_channel.py


示例18: 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_point, None)

        # test it for real
        ac = Mock(spec=pchannel.Channel)
        def cbparam(*args, **kwargs):
            cbkwarg = kwargs.get('callback')
            cbkwarg(kwargs.get('exchange'))
            return kwargs.get('exchange')
        ac.exchange_declare.side_effect = cbparam

        ch._amq_chan = ac

        ch._declare_exchange_point('hello')
        self.assertTrue(ac.exchange_declare.called)
        self.assertIn('exchange',       ac.exchange_declare.call_args[1])
        self.assertIn('type',           ac.exchange_declare.call_args[1])
        self.assertIn('durable',        ac.exchange_declare.call_args[1])
        self.assertIn('auto_delete',    ac.exchange_declare.call_args[1])
        self.assertIn('hello',          ac.exchange_declare.call_args[1].itervalues())
开发者ID:blazetopher,项目名称:pyon,代码行数:22,代码来源:test_channel.py


示例19: test_on_channel_close

    def test_on_channel_close(self):
        # er this just does logging, make the calls anyway for coverage.
        ch = BaseChannel()
        ch._amq_chan = Mock()
        ch._amq_chan.channel_number = 1

        ch.on_channel_close(0, 'hi')
        ch.on_channel_close(1, 'onoes')
开发者ID:blazetopher,项目名称:pyon,代码行数:8,代码来源:test_channel.py


示例20: test_on_channel_close_with_error_in_error_callback

    def test_on_channel_close_with_error_in_error_callback(self, logmock):
        ch = BaseChannel()
        ch.on_channel_open(Mock())
        ch._transport.channel_number = 1

        closemock = Mock()
        closemock.side_effect = StandardError
        ch.set_closed_error_callback(closemock)

        ch.on_channel_close(ch, 1, 'hi')

        self.assertEquals(logmock.warn.call_count, 1)
开发者ID:ooici,项目名称:pyon,代码行数:12,代码来源:test_channel.py



注:本文中的pyon.net.channel.BaseChannel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python endpoint.BaseEndpoint类代码示例发布时间:2022-05-27
下一篇:
Python stream.StandaloneStreamSubscriber类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap