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


Python utils.Mock類代碼示例

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


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

示例1: test_close_connection

    def test_close_connection(self):
        connection = Mock()
        connection.client = Mock()
        self.transport.close_connection(connection)

        self.assertIsNone(connection.client)
        connection.close.assert_called_with()
開發者ID:StackOps,項目名稱:kombu,代碼行數:7,代碼來源:test_pyamqp.py

示例2: test_verify_connection

    def test_verify_connection(self):
        connection = Mock()
        connection.channels = None
        self.assertFalse(self.transport.verify_connection(connection))

        connection.channels = {1: 1, 2: 2}
        self.assertTrue(self.transport.verify_connection(connection))
開發者ID:DHLabs,項目名稱:keep_isn,代碼行數:7,代碼來源:test_amqplib.py

示例3: create_get

    def create_get(self, events=None, queues=None, fanouts=None):
        _pr = [] if events is None else events
        _aq = [] if queues is None else queues
        _af = [] if fanouts is None else fanouts
        p = self.Poller()
        p.poller = Mock()
        p.poller.poll.return_value = _pr

        p._register_BRPOP = Mock()
        p._register_LISTEN = Mock()

        channel = Mock()
        p._channels = [channel]
        channel.active_queues = _aq
        channel.active_fanout_queues = _af

        return p, channel
開發者ID:StackOps,項目名稱:kombu,代碼行數:17,代碼來源:test_redis.py

示例4: test_register_LISTEN

    def test_register_LISTEN(self):
        p = self.Poller()
        channel = Mock()
        channel.subclient.connection._sock = None
        channel._in_listen = False
        p._register = Mock()

        p._register_LISTEN(channel)
        p._register.assert_called_with(channel, channel.subclient, 'LISTEN')
        self.assertEqual(p._register.call_count, 1)
        self.assertEqual(channel._subscribe.call_count, 1)

        channel._in_listen = True
        channel.subclient.connection._sock = Mock()
        p._register_LISTEN(channel)
        self.assertEqual(p._register.call_count, 1)
        self.assertEqual(channel._subscribe.call_count, 1)
開發者ID:StackOps,項目名稱:kombu,代碼行數:17,代碼來源:test_redis.py

示例5: test_register_BRPOP

    def test_register_BRPOP(self):
        p = self.Poller()
        channel = Mock()
        channel.client.connection._sock = None
        p._register = Mock()

        channel._in_poll = False
        p._register_BRPOP(channel)
        self.assertEqual(channel._brpop_start.call_count, 1)
        self.assertEqual(p._register.call_count, 1)

        channel.client.connection._sock = Mock()
        p._chan_to_sock[(channel, channel.client, 'BRPOP')] = True
        channel._in_poll = True
        p._register_BRPOP(channel)
        self.assertEqual(channel._brpop_start.call_count, 1)
        self.assertEqual(p._register.call_count, 1)
開發者ID:StackOps,項目名稱:kombu,代碼行數:17,代碼來源:test_redis.py

示例6: test_message_to_python

 def test_message_to_python(self):
     message = Mock()
     message.headers = {}
     message.properties = {}
     self.assertTrue(self.channel.message_to_python(message))
開發者ID:StackOps,項目名稱:kombu,代碼行數:5,代碼來源:test_pyamqp.py


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