本文整理汇总了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')
示例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)
示例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))
示例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)