當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。