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


Python Channel.send_reply_message方法代码示例

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


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

示例1: test_send_reply_message_event_url

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import send_reply_message [as 别名]
    def test_send_reply_message_event_url(self):
        '''Sending a message with a specified event url should store the event
        url for sending events in the future'''
        yield self.create_channel(
            self.service, self.redis, TelnetServerTransport, id='channel-id')

        in_msg = TransportUserMessage(
            from_addr='+2789',
            to_addr='+1234',
            transport_name='channel-id',
            transport_type='_',
            transport_metadata={'foo': 'bar'})

        yield self.api.inbounds.store_vumi_message('channel-id', in_msg)

        msg = yield Channel.send_reply_message(
            'channel-id', self.message_sender, self.outbounds, self.inbounds, {
                'reply_to': in_msg['message_id'],
                'content': 'testcontent',
                'event_url': 'http://test.org',
            })

        event_url = yield self.outbounds.load_event_url(
            'channel-id', msg['message_id'])

        self.assertEqual(event_url, 'http://test.org')
开发者ID:westerncapelabs,项目名称:junebug,代码行数:28,代码来源:test_channel.py

示例2: test_send_reply_message

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import send_reply_message [as 别名]
    def test_send_reply_message(self):
        '''send_reply_message should place the correct reply message on the
        correct queue'''
        yield self.create_channel(
            self.service, self.redis, TelnetServerTransport, id='channel-id')

        in_msg = TransportUserMessage(
            from_addr='+2789',
            to_addr='+1234',
            transport_name='channel-id',
            transport_type='_',
            transport_metadata={'foo': 'bar'})

        yield self.api.inbounds.store_vumi_message('channel-id', in_msg)

        msg = yield Channel.send_reply_message(
            'channel-id', self.message_sender, self.outbounds, self.inbounds, {
                'reply_to': in_msg['message_id'],
                'content': 'testcontent',
            })

        expected = in_msg.reply(content='testcontent')
        expected = conjoin(api_from_message(expected), {
            'timestamp': msg['timestamp'],
            'message_id': msg['message_id']
        })

        self.assertEqual(msg, expected)

        [dispatched] = self.get_dispatched_messages('channel-id.outbound')
        self.assertEqual(msg['message_id'], dispatched['message_id'])
        self.assertEqual(api_from_message(dispatched), expected)
开发者ID:westerncapelabs,项目名称:junebug,代码行数:34,代码来源:test_channel.py

示例3: send_message

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import send_reply_message [as 别名]
    def send_message(self, request, body, channel_id):
        '''Send an outbound (mobile terminated) message'''
        if 'to' not in body and 'reply_to' not in body:
            raise ApiUsageError(
                'Either "to" or "reply_to" must be specified')

        if 'to' in body and 'reply_to' in body:
            raise ApiUsageError(
                'Only one of "to" and "reply_to" may be specified')

        if 'from' in body and 'reply_to' in body:
            raise ApiUsageError(
                'Only one of "from" and "reply_to" may be specified')

        try:
            self.service.getServiceNamed(channel_id)
        except KeyError:
            raise ChannelNotFound()

        if 'to' in body:
            msg = yield Channel.send_message(
                channel_id, self.message_sender, self.outbounds, body)
        else:
            msg = yield Channel.send_reply_message(
                channel_id, self.message_sender, self.outbounds,
                self.inbounds, body)

        returnValue(response(request, 'message sent', msg))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:30,代码来源:api.py

示例4: test_send_reply_message_inbound_not_found

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import send_reply_message [as 别名]
    def test_send_reply_message_inbound_not_found(self):
        '''send_reply_message should raise an error if the inbound message is
        not found'''
        yield self.create_channel(
            self.service, self.redis, TelnetServerTransport, id='channel-id')

        self.assertFailure(Channel.send_reply_message(
            'channel-id', self.message_sender, self.outbounds, self.inbounds, {
                'reply_to': 'i-do-not-exist',
                'content': 'testcontent',
            }), MessageNotFound)
开发者ID:westerncapelabs,项目名称:junebug,代码行数:13,代码来源:test_channel.py


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