當前位置: 首頁>>代碼示例>>Python>>正文


Python endpoint.ListeningBaseEndpoint類代碼示例

本文整理匯總了Python中pyon.net.endpoint.ListeningBaseEndpoint的典型用法代碼示例。如果您正苦於以下問題:Python ListeningBaseEndpoint類的具體用法?Python ListeningBaseEndpoint怎麽用?Python ListeningBaseEndpoint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ListeningBaseEndpoint類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_stats

    def test_get_stats(self):
        ep = ListeningBaseEndpoint()
        ep._chan = Mock(spec=ListenChannel)

        ep.get_stats()

        ep._chan.get_stats.assert_called_once_with()
開發者ID:daf,項目名稱:pyon,代碼行數:7,代碼來源:test_endpoint.py

示例2: _setup_listener

    def _setup_listener(self, name, binding=None):
        """
        Override Subscriber - we may have specified a queue name.

        XXX BASECLASS SEEMS WRONG
        """
        ListeningBaseEndpoint._setup_listener(self, name, binding=binding)
開發者ID:blazetopher,項目名稱:pyon,代碼行數:7,代碼來源:event.py

示例3: test_listen_exception_in_handling

    def test_listen_exception_in_handling(self):

        # make a listen loop that will return one message (to blow up in processing)
        chmock = MagicMock(spec=ListenChannel)
        chmock.accept.return_value = Mock()
        chmock.accept.return_value.recv = Mock(return_value=(sentinel.msg, sentinel.headers, sentinel.delivery_tag))
        chmock.accept.return_value._recv_queue.qsize.return_value = 1

        nodemock = Mock(spec=NodeB)
        nodemock.channel.return_value = chmock

        recv_name = NameTrio(sentinel.ex, sentinel.queue)

        ep = ListeningBaseEndpoint(node=nodemock, from_name=recv_name)

        # make msg received error out!
        ep.create_endpoint = Mock(return_value=Mock(spec=EndpointUnit))
        ep.create_endpoint.return_value._message_received.side_effect = TestError
        ep.create_endpoint.return_value.intercept_in.return_value = (sentinel.msg, sentinel.headers)

        self.assertRaises(TestError, ep.listen)
        chmock.setup_listener.assert_called_once_with(recv_name, binding=sentinel.queue)
        chmock.start_consume.assert_called_once_with()

        chmock.accept.assert_called_once_with(n=1, timeout=None)
        chmock.accept.return_value.recv.assert_called_once_with()
        ep.create_endpoint.assert_called_once_with(existing_channel=chmock.accept.return_value)
開發者ID:daf,項目名稱:pyon,代碼行數:27,代碼來源:test_endpoint.py

示例4: test__create_channel_sets_transport_kwarg

    def test__create_channel_sets_transport_kwarg(self):
        # if send_name is a transport, it makes sure that kwarg is passed in to node's channel (and therefore the channel)
        class FakeSendName(NameTrio, BaseTransport):
            pass

        fn = FakeSendName()
        ep = ListeningBaseEndpoint(node=Mock(spec=NodeB), from_name=fn)

        ch = ep._create_channel()
        self.assertIn('transport', ep.node.channel.call_args[1])
        self.assertIn(fn, ep.node.channel.call_args[1].itervalues())
開發者ID:daf,項目名稱:pyon,代碼行數:11,代碼來源:test_endpoint.py

示例5: test_listen

    def test_listen(self):
        # make a listen loop that will exit right away
        chmock = Mock(spec=ListenChannel)
        chmock.accept.side_effect = ChannelClosedError

        nodemock = Mock(spec=NodeB)
        nodemock.channel.return_value = chmock

        ep = ListeningBaseEndpoint(node=nodemock, from_name=NameTrio(sentinel.ex, sentinel.queue))
        ep.listen()

        chmock.setup_listener.assert_called_once_with(ep._recv_name, binding=sentinel.queue)
開發者ID:daf,項目名稱:pyon,代碼行數:12,代碼來源:test_endpoint.py

示例6: test_listen_with_base_transport_for_name

    def test_listen_with_base_transport_for_name(self):

        # make a listen loop that will exit right away
        chmock = Mock(spec=ListenChannel)
        chmock.accept.side_effect = ChannelClosedError

        nodemock = Mock(spec=NodeB)
        nodemock.channel.return_value = chmock

        class FakeRecvName(BaseTransport, NameTrio):
            pass
        recv_name = FakeRecvName()
        recv_name.setup_listener = Mock()

        ep = ListeningBaseEndpoint(node=nodemock, from_name=recv_name)
        ep.listen(binding=sentinel.binding)

        self.assertTrue(ep.get_ready_event().is_set())
        self.assertIn('transport', nodemock.channel.call_args[1])
        self.assertIn(recv_name, nodemock.channel.call_args[1].itervalues())
開發者ID:daf,項目名稱:pyon,代碼行數:20,代碼來源:test_endpoint.py

示例7: test_get_stats_multiple_on_named_queue

    def test_get_stats_multiple_on_named_queue(self):
        ep1 = ListeningBaseEndpoint(node=self.container.node, from_name="test_get_stats_multi")
        gl1 = spawn(ep1.listen)

        ep2 = ListeningBaseEndpoint(node=self.container.node, from_name="test_get_stats_multi")
        gl2 = spawn(ep2.listen)

        ep1.get_ready_event().wait(timeout=5)
        ep2.get_ready_event().wait(timeout=5)

        gs_res1 = ep1.get_stats()
        self.assertEquals(gs_res1, (0, 2)) # num of messages, num listeners

        gs_res2 = ep2.get_stats()
        self.assertEquals(gs_res2, (0, 2)) # num of messages, num listeners

        ep1.close()
        ep2.close()
        gl1.join(timeout=5)
        gl2.join(timeout=5)
開發者ID:daf,項目名稱:pyon,代碼行數:20,代碼來源:test_endpoint.py

示例8: test_close

    def test_close(self):
        ep = ListeningBaseEndpoint(node=Mock(soec=NodeB))
        ep._chan = Mock()
        ep.close()

        ep._chan.close.assert_called_once_with()
開發者ID:daf,項目名稱:pyon,代碼行數:6,代碼來源:test_endpoint.py

示例9: test_get_ready_event

 def test_get_ready_event(self):
     ep = ListeningBaseEndpoint(node=Mock(spec=NodeB))
     self.assertEquals(ep.get_ready_event(), ep._ready_event)
開發者ID:daf,項目名稱:pyon,代碼行數:3,代碼來源:test_endpoint.py


注:本文中的pyon.net.endpoint.ListeningBaseEndpoint類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。