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


Python TransportUserMessage.send方法代码示例

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


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

示例1: test_message_sender_send_multiple_messages

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
    def test_message_sender_send_multiple_messages(self):
        '''The message sender should send all messages to their correct queues
        when send_message is called multiple times'''
        msg1 = TransportUserMessage.send(
            to_addr='+1234', content='test1', transport_name='testtransport')
        yield self.message_sender.send_message(
            msg1, routing_key='testtransport')
        msg2 = TransportUserMessage.send(
            to_addr='+1234', content='test2', transport_name='testtransport')
        yield self.message_sender.send_message(
            msg2, routing_key='testtransport')

        [rec_msg1, rec_msg2] = self.get_dispatched_messages('testtransport')
        self.assertEqual(rec_msg1, msg1)
        self.assertEqual(rec_msg2, msg2)
开发者ID:BantouTelecom,项目名称:junebug,代码行数:17,代码来源:test_amqp.py

示例2: send_to

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def send_to(self, to_addr, content, tag='default', **kw):
     if tag not in self.SEND_TO_TAGS:
         raise ValueError("Tag %r not defined in SEND_TO_TAGS" % (tag,))
     options = copy.deepcopy(self.send_to_options[tag])
     options.update(kw)
     msg = TransportUserMessage.send(to_addr, content, **options)
     return self._publish_message(msg)
开发者ID:BantouTelecom,项目名称:vumi,代码行数:9,代码来源:base.py

示例3: test_send_to

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def test_send_to(self):
     sent_msg = yield self.send_to('+12345', "Hi!")
     sends = self.app_helper.get_dispatched_outbound()
     expecteds = [TransportUserMessage.send('+12345', "Hi!",
             transport_name='default_transport')]
     self.assert_msgs_match(sends, expecteds)
     self.assert_msgs_match(sends, [sent_msg])
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:9,代码来源:test_base.py

示例4: send_message

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def send_message(self, sender, outbounds, msg):
     '''Sends a message.'''
     event_url = msg.get('event_url')
     msg = message_from_api(self.id, msg)
     msg = TransportUserMessage.send(**msg)
     msg = yield self._send_message(sender, outbounds, event_url, msg)
     returnValue(api_from_message(msg))
开发者ID:BantouTelecom,项目名称:junebug,代码行数:9,代码来源:channel.py

示例5: test_send_to

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def test_send_to(self):
     sent_msg = yield self.worker.send_to('+12345', "Hi!")
     sends = self.recv()
     expecteds = [TransportUserMessage.send('+12345', "Hi!",
             transport_name='default_transport')]
     self.assert_msgs_match(sends, expecteds)
     self.assert_msgs_match(sends, [sent_msg])
开发者ID:BantouTelecom,项目名称:vumi,代码行数:9,代码来源:test_base.py

示例6: test_send_to_with_tag

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def test_send_to_with_tag(self):
     sent_msg = yield self.worker.send_to('+12345', "Hi!", "outbound1",
             transport_type=TransportUserMessage.TT_USSD)
     sends = self.recv()
     expecteds = [TransportUserMessage.send('+12345', "Hi!",
             transport_type=TransportUserMessage.TT_USSD,
             transport_name='outbound1_transport')]
     self.assert_msgs_match(sends, expecteds)
     self.assert_msgs_match(sends, [sent_msg])
开发者ID:BantouTelecom,项目名称:vumi,代码行数:11,代码来源:test_base.py

示例7: test_send_message_storing

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
    def test_send_message_storing(self):
        """Inbound messages should be stored in the InboundMessageStore"""
        msg = TransportUserMessage.send(to_addr="+1234", content="testcontent")
        yield self.worker.consume_user_message(msg)

        redis = self.worker.redis
        key = "%s:inbound_messages:%s" % (self.worker.config["transport_name"], msg["message_id"])
        msg_json = yield redis.hget(key, "message")
        self.assertEqual(TransportUserMessage.from_json(msg_json), msg)
开发者ID:westerncapelabs,项目名称:junebug,代码行数:11,代码来源:test_workers.py

示例8: test_send_message

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
    def test_send_message(self):
        """A sent message should be forwarded to the configured URL"""
        msg = TransportUserMessage.send(to_addr="+1234", content="testcontent")
        yield self.worker.consume_user_message(msg)
        [req] = self.logging_api.requests

        self.assert_request(req, method="POST", headers={"content-type": ["application/json"]})

        self.assert_body_contains(req, to="+1234", content="testcontent")
开发者ID:westerncapelabs,项目名称:junebug,代码行数:11,代码来源:test_workers.py

示例9: test_message_sender_bad_routing_key

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def test_message_sender_bad_routing_key(self):
     '''If the routing key is invalid, the message sender should raise an
     error'''
     msg = TransportUserMessage.send(
         to_addr='+1234', content='test', transport_name='testtransport')
     err = yield self.assertFailure(
         self.message_sender.send_message(msg, routing_key='Foo'),
         RoutingKeyError)
     self.assertTrue('Foo' in str(err))
开发者ID:BantouTelecom,项目名称:junebug,代码行数:11,代码来源:test_amqp.py

示例10: test_store_vumi_message

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def test_store_vumi_message(self):
     '''Stores the vumi message.'''
     store = yield self.create_store()
     vumi_msg = TransportUserMessage.send(to_addr='+213', content='foo')
     yield store.store_vumi_message('channel_id', vumi_msg)
     msg = yield self.redis.hget(
         'channel_id:inbound_messages:%s' % vumi_msg.get('message_id'),
         'message')
     self.assertEqual(vumi_msg, TransportUserMessage.from_json(msg))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:11,代码来源:test_stores.py

示例11: test_message_sender_send_message

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def test_message_sender_send_message(self):
     '''The message sender should add a message to the correct queue when
     send_message is called'''
     msg = TransportUserMessage.send(
         to_addr='+1234', content='test', transport_name='testtransport')
     yield self.message_sender.send_message(
         msg, routing_key='testtransport')
     [rec_msg] = self.get_dispatched_messages('testtransport')
     self.assertEqual(rec_msg, msg)
开发者ID:BantouTelecom,项目名称:junebug,代码行数:11,代码来源:test_amqp.py

示例12: test_send_to_with_different_endpoint

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def test_send_to_with_different_endpoint(self):
     sent_msg = yield self.worker.send_to(
         "+12345", "Hi!", endpoint="outbound1", transport_type=TransportUserMessage.TT_USSD
     )
     sends = self.app_helper.get_dispatched_outbound()
     expecteds = [TransportUserMessage.send("+12345", "Hi!", transport_type=TransportUserMessage.TT_USSD)]
     expecteds[0].set_routing_endpoint("outbound1")
     self.assert_msgs_match(sends, [sent_msg])
     self.assert_msgs_match(sends, expecteds)
开发者ID:Nagato23,项目名称:vumi,代码行数:11,代码来源:test_base.py

示例13: test_send_to_with_endpoint

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def test_send_to_with_endpoint(self):
     sent_msg = yield self.send_to('+12345', "Hi!", "outbound1",
             transport_type=TransportUserMessage.TT_USSD)
     sends = self.app_helper.get_dispatched_outbound()
     expecteds = [TransportUserMessage.send('+12345', "Hi!",
             transport_type=TransportUserMessage.TT_USSD,
             transport_name='outbound1_transport')]
     expecteds[0].set_routing_endpoint("outbound1")
     self.assert_msgs_match(sends, expecteds)
     self.assert_msgs_match(sends, [sent_msg])
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:12,代码来源:test_base.py

示例14: test_send_message_storing

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
    def test_send_message_storing(self):
        '''Inbound messages should be stored in the InboundMessageStore'''
        msg = TransportUserMessage.send(to_addr='+1234', content='testcontent')
        yield self.worker.consume_user_message(msg)

        redis = self.worker.redis
        key = '%s:inbound_messages:%s' % (
            self.worker.config['transport_name'], msg['message_id'])
        msg_json = yield redis.hget(key, 'message')
        self.assertEqual(TransportUserMessage.from_json(msg_json), msg)
开发者ID:BantouTelecom,项目名称:junebug,代码行数:12,代码来源:test_workers.py

示例15: test_send_to_with_options

# 需要导入模块: from vumi.message import TransportUserMessage [as 别名]
# 或者: from vumi.message.TransportUserMessage import send [as 别名]
 def test_send_to_with_options(self):
     sent_msg = yield self.send_to("+12345", "Hi!", transport_type=TransportUserMessage.TT_USSD)
     sends = self.app_helper.get_dispatched_outbound()
     expecteds = [
         TransportUserMessage.send(
             "+12345", "Hi!", transport_type=TransportUserMessage.TT_USSD, transport_name="default_transport"
         )
     ]
     self.assert_msgs_match(sends, expecteds)
     self.assert_msgs_match(sends, [sent_msg])
开发者ID:Nagato23,项目名称:vumi,代码行数:12,代码来源:test_base.py


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