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


Python DeliverSM.get_bin方法代码示例

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


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

示例1: test_deliver_sm_message_payload

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def test_deliver_sm_message_payload(self):
     """A message in the `message_payload` field should be delivered."""
     esme = yield self.get_esme(
         deliver_sm=self.assertion_cb(u'hello', 'short_message'))
     sm = DeliverSM(1, short_message='')
     sm.add_message_payload(''.join('%02x' % ord(c) for c in 'hello'))
     yield esme.handle_deliver_sm(unpack_pdu(sm.get_bin()))
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:9,代码来源:test_client.py

示例2: test_send_pdu

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
    def test_send_pdu(self):
        """
        A PDU can be sent to the client over the wire.
        """
        fake_smsc = FakeSMSC()
        client = self.successResultOf(self.connect(fake_smsc))
        self.assertEqual(client.received, b"")
        self.assertEqual(client.pdus_handled, [])

        pdu = DeliverSM(0)
        send_d = fake_smsc.send_pdu(pdu)
        # PDU sent, not yet received.
        self.assertNoResult(send_d)
        self.assertNotEqual(client.received, pdu.get_bin())

        yield send_d
        # PDU received.
        self.assertEqual(client.received, pdu.get_bin())
        self.assertEqual(client.pdus_handled, [])
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:21,代码来源:test_fake_smsc.py

示例3: test_deliver_sm

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def test_deliver_sm(self):
     calls = []
     self.patch(EsmeTransceiver, 'handle_deliver_sm',
                lambda p, pdu: succeed(calls.append(pdu)))
     transport, protocol = yield self.setup_bind()
     pdu = DeliverSM(
         sequence_number=0, message_id='foo', short_message='bar')
     protocol.dataReceived(pdu.get_bin())
     [deliver_sm] = calls
     self.assertCommand(deliver_sm, 'deliver_sm', sequence_number=0)
开发者ID:areski,项目名称:vumi,代码行数:12,代码来源:test_protocol.py

示例4: test_deliver_sm_fail

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def test_deliver_sm_fail(self):
     transport, protocol = yield self.setup_bind()
     pdu = DeliverSM(
         sequence_number=0, message_id='foo', data_coding=4,
         short_message='string with unknown data coding')
     protocol.dataReceived(pdu.get_bin())
     [deliver_sm_resp] = yield wait_for_pdus(transport, 1)
     self.assertCommand(
         deliver_sm_resp, 'deliver_sm_resp', sequence_number=0,
         status='ESME_RDELIVERYFAILURE')
开发者ID:Nagato23,项目名称:vumi,代码行数:12,代码来源:test_protocol.py

示例5: test_delivery_report_for_unknown_message

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def test_delivery_report_for_unknown_message(self):
     dr = ("id:123 sub:... dlvrd:... submit date:200101010030"
           " done date:200101020030 stat:DELIVRD err:... text:Meep")
     deliver = DeliverSM(1, short_message=dr)
     with LogCatcher(message="Failed to retrieve message id") as lc:
         yield self.esme.handle_data(deliver.get_bin())
         [warning] = lc.logs
         self.assertEqual(warning['message'],
                          ("Failed to retrieve message id for delivery "
                           "report. Delivery report from %s "
                           "discarded." % self.tx_helper.transport_name,))
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:13,代码来源:test_smpp.py

示例6: test_deliver_sm_fail

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def test_deliver_sm_fail(self):
     self.patch(DeliverShortMessageProcessor, 'decode_pdus',
                lambda *a: [str('not a unicode string')])
     transport, protocol = yield self.setup_bind()
     pdu = DeliverSM(
         sequence_number=0, message_id='foo', short_message='bar')
     protocol.dataReceived(pdu.get_bin())
     [deliver_sm_resp] = yield wait_for_pdus(transport, 1)
     self.assertCommand(
         deliver_sm_resp, 'deliver_sm_resp', sequence_number=0,
         status='ESME_RDELIVERYFAILURE')
开发者ID:areski,项目名称:vumi,代码行数:13,代码来源:test_protocol.py

示例7: test_deliver_sm_fail_with_custom_error

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def test_deliver_sm_fail_with_custom_error(self):
     transport, protocol = yield self.setup_bind(config={
         "deliver_sm_decoding_error": "ESME_RSYSERR"
     })
     pdu = DeliverSM(
         sequence_number=0, message_id='foo', data_coding=4,
         short_message='string with unknown data coding')
     protocol.dataReceived(pdu.get_bin())
     [deliver_sm_resp] = yield wait_for_pdus(transport, 1)
     self.assertCommand(
         deliver_sm_resp, 'deliver_sm_resp', sequence_number=0,
         status='ESME_RSYSERR')
开发者ID:Nagato23,项目名称:vumi,代码行数:14,代码来源:test_protocol.py

示例8: test_deliver_sm_ussd_start

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
    def test_deliver_sm_ussd_start(self):
        def assert_ussd(value):
            self.assertEqual('ussd', value['message_type'])
            self.assertEqual('new', value['session_event'])
            self.assertEqual(None, value['short_message'])

        esme = yield self.get_esme(deliver_sm=self.make_cb(assert_ussd))

        sm = DeliverSM(1)
        sm._PDU__add_optional_parameter('ussd_service_op', '01')
        sm._PDU__add_optional_parameter('its_session_info', '0000')

        yield esme.handle_deliver_sm(unpack_pdu(sm.get_bin()))
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:15,代码来源:test_client.py

示例9: test_deliver_sm_delivery_report_regex_fallback_ucs2_long

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
    def test_deliver_sm_delivery_report_regex_fallback_ucs2_long(self):
        esme = yield self.get_esme(delivery_report=self.assertion_cb({
            'message_id': '1b1720be-5f48-41c4-b3f8-6e59dbf45366',
            'message_state': 'DELIVRD',
        }))

        dr_text = (
            u'id:1b1720be-5f48-41c4-b3f8-6e59dbf45366 sub:001 dlvrd:001 '
            u'submit date:120726132548 done date:120726132548 stat:DELIVRD '
            u'err:000 text:').encode('utf-16be')
        sm = DeliverSM(1, short_message='', data_coding=8)
        sm.add_message_payload(dr_text.encode('hex'))
        yield esme.handle_deliver_sm(unpack_pdu(sm.get_bin()))
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:15,代码来源:test_client.py

示例10: test_deliver_sm_delivery_report_rejected

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
    def test_deliver_sm_delivery_report_rejected(self):
        esme = yield self.get_esme(delivery_report=self.assertion_cb({
            'message_id': '1b1720be-5f48-41c4-b3f8-6e59dbf45366',
            'message_state': 'REJECTED',
        }))

        sm = DeliverSM(1, short_message='delivery report')
        sm._PDU__add_optional_parameter(
            'receipted_message_id',
            '1b1720be-5f48-41c4-b3f8-6e59dbf45366')
        sm._PDU__add_optional_parameter('message_state', 8)

        yield esme.handle_deliver_sm(unpack_pdu(sm.get_bin()))
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:15,代码来源:test_client.py

示例11: test_deliver_sm_fail_with_custom_error

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def test_deliver_sm_fail_with_custom_error(self):
     self.patch(DeliverShortMessageProcessor, 'decode_pdus',
                lambda *a: [str('not a unicode string')])
     transport, protocol = yield self.setup_bind(config={
         "deliver_sm_decoding_error": "ESME_RSYSERR"
     })
     pdu = DeliverSM(
         sequence_number=0, message_id='foo', short_message='bar')
     protocol.dataReceived(pdu.get_bin())
     [deliver_sm_resp] = yield wait_for_pdus(transport, 1)
     self.assertCommand(
         deliver_sm_resp, 'deliver_sm_resp', sequence_number=0,
         status='ESME_RSYSERR')
开发者ID:areski,项目名称:vumi,代码行数:15,代码来源:test_protocol.py

示例12: test_partial_pdu_data_received

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def test_partial_pdu_data_received(self):
     calls = []
     self.patch(EsmeTransceiver, 'handle_deliver_sm',
                lambda p, pdu: calls.append(pdu))
     transport, protocol = yield self.setup_bind()
     deliver_sm = DeliverSM(sequence_number=1, short_message='foo')
     pdu = deliver_sm.get_bin()
     half = len(pdu) / 2
     pdu_part1, pdu_part2 = pdu[:half], pdu[half:]
     protocol.dataReceived(pdu_part1)
     self.assertEqual([], calls)
     protocol.dataReceived(pdu_part2)
     [handled_pdu] = calls
     self.assertEqual(command_id(handled_pdu), 'deliver_sm')
     self.assertEqual(seq_no(handled_pdu), 1)
     self.assertEqual(short_message(handled_pdu), 'foo')
开发者ID:areski,项目名称:vumi,代码行数:18,代码来源:test_protocol.py

示例13: test_partial_pdu_data_received

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def test_partial_pdu_data_received(self):
     protocol = yield self.get_protocol()
     calls = []
     protocol.handle_deliver_sm = calls.append
     yield self.fake_smsc.bind()
     deliver_sm = DeliverSM(1, short_message='foo')
     pdu = deliver_sm.get_bin()
     half = len(pdu) / 2
     pdu_part1, pdu_part2 = pdu[:half], pdu[half:]
     yield self.fake_smsc.send_bytes(pdu_part1)
     self.assertEqual([], calls)
     yield self.fake_smsc.send_bytes(pdu_part2)
     [handled_pdu] = calls
     self.assertEqual(command_id(handled_pdu), 'deliver_sm')
     self.assertEqual(seq_no(handled_pdu), 1)
     self.assertEqual(short_message(handled_pdu), 'foo')
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:18,代码来源:test_protocol.py

示例14: get_sm

# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import get_bin [as 别名]
 def get_sm(self, msg, data_coding=3):
     sm = DeliverSM(1, short_message=msg, data_coding=data_coding)
     return unpack_pdu(sm.get_bin())
开发者ID:BantouTelecom,项目名称:vumi,代码行数:5,代码来源:test_client.py


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