当前位置: 首页>>代码示例>>Python>>正文


Python HttpClient.get_next_message方法代码示例

本文整理汇总了Python中channels.tests.HttpClient.get_next_message方法的典型用法代码示例。如果您正苦于以下问题:Python HttpClient.get_next_message方法的具体用法?Python HttpClient.get_next_message怎么用?Python HttpClient.get_next_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在channels.tests.HttpClient的用法示例。


在下文中一共展示了HttpClient.get_next_message方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_demultiplexer_without_payload_and_steam

# 需要导入模块: from channels.tests import HttpClient [as 别名]
# 或者: from channels.tests.HttpClient import get_next_message [as 别名]
    def test_demultiplexer_without_payload_and_steam(self):
        class Demultiplexer(WebsocketDemultiplexer):
            mapping = {
                'users': 'binding.users',
            }

            groups = ['inbound']

        with apply_routes([Demultiplexer.as_route(path='/')]):
            client = HttpClient()
            client.send_and_consume('websocket.connect', path='/')

            with self.assertRaises(ValueError) as value_error:
                client.send_and_consume('websocket.receive', path='/', text={
                    'nostream': 'users', 'payload': 'test',
                })

            self.assertIn('no channel/payload key', value_error.exception.args[0])

            message = client.get_next_message('binding.users')
            self.assertIsNone(message)

            with self.assertRaises(ValueError) as value_error:
                client.send_and_consume('websocket.receive', path='/', text={
                    'stream': 'users',
                })

            self.assertIn('no channel/payload key', value_error.exception.args[0])

            message = client.get_next_message('binding.users')
            self.assertIsNone(message)
开发者ID:raiderrobert,项目名称:channels,代码行数:33,代码来源:test_binding.py

示例2: test_demultiplexer_with_wrong_payload

# 需要导入模块: from channels.tests import HttpClient [as 别名]
# 或者: from channels.tests.HttpClient import get_next_message [as 别名]
    def test_demultiplexer_with_wrong_payload(self):
        class Demultiplexer(WebsocketDemultiplexer):
            mapping = {
                'users': 'binding.users',
            }

            groups = ['inbound']

        with apply_routes([Demultiplexer.as_route(path='/')]):
            client = HttpClient()
            client.send_and_consume('websocket.connect', path='/')

            with self.assertRaises(ValueError) as value_error:
                client.send_and_consume('websocket.receive', path='/', text={
                    'stream': 'users', 'payload': 'test',
                })

            self.assertEqual(value_error.exception.args[0], 'Multiplexed frame payload is not a dict')

            message = client.get_next_message('binding.users')
            self.assertIsNone(message)
开发者ID:raiderrobert,项目名称:channels,代码行数:23,代码来源:test_binding.py

示例3: test_demultiplexer

# 需要导入模块: from channels.tests import HttpClient [as 别名]
# 或者: from channels.tests.HttpClient import get_next_message [as 别名]
    def test_demultiplexer(self):
        class Demultiplexer(WebsocketDemultiplexer):
            mapping = {
                'users': 'binding.users',
            }

            groups = ['inbound']

        with apply_routes([Demultiplexer.as_route(path='/')]):
            client = HttpClient()
            client.send_and_consume('websocket.connect', path='/')

            # assert in group
            Group('inbound').send({'text': json.dumps({'test': 'yes'})}, immediately=True)
            self.assertEqual(client.receive(), {'test': 'yes'})

            # assert that demultiplexer stream message
            client.send_and_consume('websocket.receive', path='/',
                                    text={'stream': 'users', 'payload': {'test': 'yes'}})
            message = client.get_next_message('binding.users')
            self.assertIsNotNone(message)
            self.assertEqual(message.content['test'], 'yes')
开发者ID:raiderrobert,项目名称:channels,代码行数:24,代码来源:test_binding.py


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