本文整理汇总了Python中smpp.pdu_builder.DeliverSM类的典型用法代码示例。如果您正苦于以下问题:Python DeliverSM类的具体用法?Python DeliverSM怎么用?Python DeliverSM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DeliverSM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_submit_and_deliver_ussd_new_custom_ussd_code_field
def test_submit_and_deliver_ussd_new_custom_ussd_code_field(self):
session = SessionInfo()
yield self.get_transport(deliver_config={
'ussd_code_pdu_field': 'destination_addr',
})
# Server delivers a USSD message to the Client
pdu = DeliverSM(1, short_message="*IGNORE#", destination_addr="*123#")
pdu.add_optional_parameter('ussd_service_op', '01')
pdu.add_optional_parameter('its_session_info', session.its_info)
yield self.fake_smsc.handle_pdu(pdu)
[mess] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(mess['content'], None)
self.assertEqual(mess['to_addr'], '*123#')
self.assertEqual(mess['transport_type'], "ussd")
self.assertEqual(mess['session_event'],
TransportUserMessage.SESSION_NEW)
self.assertEqual(
mess['transport_metadata'],
{
'session_info': {
'session_identifier': session.sixdee_id,
'ussd_service_op': '01',
}
})
示例2: test_submit_and_deliver_ussd_new
def test_submit_and_deliver_ussd_new(self):
session_identifier = 12345
smpp_helper = yield self.get_smpp_helper()
# Server delivers a USSD message to the Client
pdu = DeliverSM(1, short_message="*123#")
pdu.add_optional_parameter('ussd_service_op', '01')
pdu.add_optional_parameter('user_message_reference',
session_identifier)
yield smpp_helper.handle_pdu(pdu)
[mess] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(mess['content'], None)
self.assertEqual(mess['to_addr'], '*123#')
self.assertEqual(mess['transport_type'], "ussd")
self.assertEqual(mess['session_event'],
TransportUserMessage.SESSION_NEW)
self.assertEqual(
mess['transport_metadata'],
{
'session_info': {
'session_identifier': 12345
}
})
示例3: test_deliver_sm_message_payload
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()))
示例4: test_submit_and_deliver_ussd_continue
def test_submit_and_deliver_ussd_continue(self):
# Startup
yield self.startTransport()
yield self.transport._block_till_bind
yield self.clear_link_pdus()
# Next the Client submits a USSD message to the Server
# and recieves an ack
msg = yield self.tx_helper.make_dispatch_outbound(
"hello world", transport_type="ussd")
# First we make sure the Client binds to the Server
# and enquire_link pdu's are exchanged as expected
pdu_queue = self.service.factory.smsc.pdu_queue
submit_sm_pdu = yield pdu_queue.get()
self.assert_server_pdu(
mk_expected_pdu('inbound', 3, 'submit_sm'), submit_sm_pdu)
pdu_opts = unpacked_pdu_opts(submit_sm_pdu['pdu'])
self.assertEqual('02', pdu_opts['ussd_service_op'])
self.assertEqual('0000', pdu_opts['its_session_info'])
# We need the user_message_id to check the ack
user_message_id = msg.payload["message_id"]
[ack, delv] = yield self.tx_helper.wait_for_dispatched_events(2)
self.assertEqual(ack['message_type'], 'event')
self.assertEqual(ack['event_type'], 'ack')
self.assertEqual(ack['transport_name'], self.tx_helper.transport_name)
self.assertEqual(ack['user_message_id'], user_message_id)
self.assertEqual(delv['message_type'], 'event')
self.assertEqual(delv['event_type'], 'delivery_report')
self.assertEqual(delv['transport_name'], self.tx_helper.transport_name)
self.assertEqual(delv['user_message_id'], user_message_id)
self.assertEqual(delv['delivery_status'],
self.expected_delivery_status)
# Finally the Server delivers a USSD message to the Client
pdu = DeliverSM(555,
short_message="reply!",
destination_addr="2772222222",
source_addr="2772000000")
pdu._PDU__add_optional_parameter('ussd_service_op', '02')
pdu._PDU__add_optional_parameter('its_session_info', '0000')
self.service.factory.smsc.send_pdu(pdu)
[mess] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(mess['message_type'], 'user_message')
self.assertEqual(mess['transport_name'], self.tx_helper.transport_name)
self.assertEqual(mess['content'], "reply!")
self.assertEqual(mess['transport_type'], "ussd")
self.assertEqual(mess['session_event'],
TransportUserMessage.SESSION_RESUME)
self.assertEqual([], self.tx_helper.get_dispatched_failures())
示例5: test_submit_and_deliver_ussd_close
def test_submit_and_deliver_ussd_close(self):
smpp_helper = yield self.get_smpp_helper()
yield self.tx_helper.make_dispatch_outbound(
"hello world", transport_type="ussd",
session_event=TransportUserMessage.SESSION_CLOSE)
[submit_sm_pdu] = yield smpp_helper.wait_for_pdus(1)
self.assertEqual(command_id(submit_sm_pdu), 'submit_sm')
self.assertEqual(pdu_tlv(submit_sm_pdu, 'ussd_service_op'), '02')
self.assertEqual(pdu_tlv(submit_sm_pdu, 'its_session_info'), '0001')
# Server delivers a USSD message to the Client
pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!")
pdu.add_optional_parameter('ussd_service_op', '02')
pdu.add_optional_parameter('its_session_info', '0001')
yield smpp_helper.handle_pdu(pdu)
[mess] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(mess['content'], "reply!")
self.assertEqual(mess['transport_type'], "ussd")
self.assertEqual(mess['session_event'],
TransportUserMessage.SESSION_CLOSE)
示例6: test_deliver_sm_op_codes_new
def test_deliver_sm_op_codes_new(self):
session_identifier = 12345
yield self.get_transport()
pdu = DeliverSM(1, short_message="*123#")
pdu.add_optional_parameter("ussd_service_op", "01")
pdu.add_optional_parameter("user_message_reference", session_identifier)
yield self.fake_smsc.handle_pdu(pdu)
[start] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(start["session_event"], TransportUserMessage.SESSION_NEW)
示例7: test_deliver_sm_fail
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')
示例8: test_deliver_sm_op_codes_new
def test_deliver_sm_op_codes_new(self):
session = SessionInfo()
yield self.get_transport()
pdu = DeliverSM(1, short_message="*123#")
pdu.add_optional_parameter('ussd_service_op', '01')
pdu.add_optional_parameter('its_session_info', session.its_info)
yield self.fake_smsc.handle_pdu(pdu)
[start] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(start['session_event'],
TransportUserMessage.SESSION_NEW)
示例9: test_deliver_sm
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)
示例10: test_delivery_report_for_unknown_message
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,))
示例11: test_deliver_sm_op_codes_new
def test_deliver_sm_op_codes_new(self):
session_identifier = 12345
smpp_helper = yield self.get_smpp_helper()
pdu = DeliverSM(1, short_message="*123#")
pdu.add_optional_parameter('ussd_service_op', '01')
pdu.add_optional_parameter('user_message_reference',
session_identifier)
yield smpp_helper.handle_pdu(pdu)
[start] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(start['session_event'],
TransportUserMessage.SESSION_NEW)
示例12: test_deliver_sm_fail
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')
示例13: test_deliver_sm_fail_with_custom_error
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')
示例14: test_mo_sms_multipart_long
def test_mo_sms_multipart_long(self):
smpp_helper = yield self.get_smpp_helper()
content = '1' * 255
pdu = DeliverSM(sequence_number=1)
pdu.add_optional_parameter('message_payload', content.encode('hex'))
smpp_helper.send_pdu(pdu)
[deliver_sm_resp] = yield smpp_helper.wait_for_pdus(1)
self.assertEqual(1, seq_no(deliver_sm_resp))
self.assertTrue(pdu_ok(deliver_sm_resp))
[msg] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(msg['content'], content)
示例15: test_deliver_sm_delivery_report_regex_fallback_ucs2_long
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()))