本文整理汇总了Python中smpp.pdu_builder.DeliverSM._PDU__add_optional_parameter方法的典型用法代码示例。如果您正苦于以下问题:Python DeliverSM._PDU__add_optional_parameter方法的具体用法?Python DeliverSM._PDU__add_optional_parameter怎么用?Python DeliverSM._PDU__add_optional_parameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smpp.pdu_builder.DeliverSM
的用法示例。
在下文中一共展示了DeliverSM._PDU__add_optional_parameter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_submit_and_deliver_ussd_continue
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import _PDU__add_optional_parameter [as 别名]
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())
示例2: test_deliver_sm_ussd_start
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import _PDU__add_optional_parameter [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()))
示例3: test_deliver_sm_delivery_report_rejected
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import _PDU__add_optional_parameter [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()))
示例4: test_deliver_ussd_start
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import _PDU__add_optional_parameter [as 别名]
def test_deliver_ussd_start(self):
# Startup
yield self.startTransport()
yield self.transport._block_till_bind
# The Server delivers a SMS to the Client
pdu = DeliverSM(
555, destination_addr="2772222222", source_addr="2772000000")
pdu._PDU__add_optional_parameter('ussd_service_op', '01')
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['transport_type'], 'ussd')
self.assertEqual(mess['transport_name'], self.tx_helper.transport_name)
self.assertEqual(mess['content'], None)
self.assertEqual(mess['session_event'],
TransportUserMessage.SESSION_NEW)
dispatched_failures = self.tx_helper.get_dispatched_failures()
self.assertEqual(dispatched_failures, [])