本文整理汇总了Python中smpp.pdu_builder.DeliverSM.add_optional_parameter方法的典型用法代码示例。如果您正苦于以下问题:Python DeliverSM.add_optional_parameter方法的具体用法?Python DeliverSM.add_optional_parameter怎么用?Python DeliverSM.add_optional_parameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smpp.pdu_builder.DeliverSM
的用法示例。
在下文中一共展示了DeliverSM.add_optional_parameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_submit_and_deliver_ussd_new
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
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
}
})
示例2: test_submit_and_deliver_ussd_new_custom_ussd_code_field
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
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',
}
})
示例3: test_submit_and_deliver_ussd_close
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
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)
示例4: test_deliver_sm_op_codes_new
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
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)
示例5: test_deliver_sm_op_codes_new
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
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)
示例6: test_deliver_sm_op_codes_new
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
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)
示例7: test_mo_sms_multipart_long
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
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)
示例8: test_mo_delivery_report_pdu
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
def test_mo_delivery_report_pdu(self):
smpp_helper = yield self.get_smpp_helper()
transport = smpp_helper.transport
yield transport.message_stash.set_remote_message_id('bar', 'foo')
pdu = DeliverSM(sequence_number=1)
pdu.add_optional_parameter('receipted_message_id', 'foo')
pdu.add_optional_parameter('message_state', 2)
yield smpp_helper.handle_pdu(pdu)
[event] = yield self.tx_helper.wait_for_dispatched_events(1)
self.assertEqual(event['event_type'], 'delivery_report')
self.assertEqual(event['delivery_status'], 'delivered')
self.assertEqual(event['user_message_id'], 'bar')
示例9: test_deliver_sm_op_codes_end
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
def test_deliver_sm_op_codes_end(self):
session = SessionInfo()
transport = yield self.get_transport()
deliver_sm_processor = transport.deliver_sm_processor
session_manager = deliver_sm_processor.session_manager
yield session_manager.create_session(
session.vumi_id, ussd_code='*123#')
pdu = DeliverSM(1, short_message="", source_addr=session.addr)
pdu.add_optional_parameter('ussd_service_op', '81')
pdu.add_optional_parameter('its_session_info', session.its_info)
yield self.fake_smsc.handle_pdu(pdu)
[end] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(end['session_event'],
TransportUserMessage.SESSION_CLOSE)
示例10: test_deliver_sm_op_codes_resume
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
def test_deliver_sm_op_codes_resume(self):
session = SessionInfo()
smpp_helper = yield self.get_smpp_helper()
deliver_sm_processor = smpp_helper.transport.deliver_sm_processor
session_manager = deliver_sm_processor.session_manager
yield session_manager.create_session(
session.vumi_id, ussd_code='*123#')
pdu = DeliverSM(1, short_message="", source_addr=session.addr)
pdu.add_optional_parameter('ussd_service_op', '12')
pdu.add_optional_parameter('its_session_info', session.its_info)
yield smpp_helper.handle_pdu(pdu)
[resume] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(resume['session_event'],
TransportUserMessage.SESSION_RESUME)
示例11: test_deliver_sm_op_codes_end
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
def test_deliver_sm_op_codes_end(self):
source_addr = "msisdn"
session_identifier = 12345
vumi_session_identifier = make_vumi_session_identifier(source_addr, session_identifier)
transport = yield self.get_transport()
deliver_sm_processor = transport.deliver_sm_processor
session_manager = deliver_sm_processor.session_manager
yield session_manager.create_session(vumi_session_identifier, ussd_code="*123#")
pdu = DeliverSM(1, short_message="", source_addr=source_addr)
pdu.add_optional_parameter("ussd_service_op", "81")
pdu.add_optional_parameter("user_message_reference", session_identifier)
yield self.fake_smsc.handle_pdu(pdu)
[end] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(end["session_event"], TransportUserMessage.SESSION_CLOSE)
示例12: test_submit_and_deliver_ussd_continue
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
def test_submit_and_deliver_ussd_continue(self):
user_msisdn = 'msisdn'
session_identifier = 12345
vumi_session_identifier = make_vumi_session_identifier(
user_msisdn, session_identifier)
smpp_helper = yield self.get_smpp_helper()
deliver_sm_processor = smpp_helper.transport.deliver_sm_processor
session_manager = deliver_sm_processor.session_manager
yield session_manager.create_session(
vumi_session_identifier, ussd_code='*123#')
yield self.tx_helper.make_dispatch_outbound(
"hello world", transport_type="ussd", transport_metadata={
'session_info': {
'session_identifier': session_identifier
}
}, to_addr=user_msisdn)
[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, 'user_message_reference'),
session_identifier)
# Server delivers a USSD message to the Client
pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!",
source_addr=user_msisdn)
# 0x12 is 'continue'
pdu.add_optional_parameter('ussd_service_op', '12')
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'], "reply!")
self.assertEqual(mess['transport_type'], "ussd")
self.assertEqual(mess['to_addr'], '*123#')
self.assertEqual(mess['session_event'],
TransportUserMessage.SESSION_RESUME)
示例13: test_submit_and_deliver_ussd_new
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
def test_submit_and_deliver_ussd_new(self):
session_identifier = 12345
yield self.get_transport()
# 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 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": 12345, "ussd_service_op": "01"}}
)
示例14: test_deliver_sm_op_codes_end
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
def test_deliver_sm_op_codes_end(self):
source_addr = 'msisdn'
session_identifier = 12345
vumi_session_identifier = make_vumi_session_identifier(
source_addr, session_identifier)
smpp_helper = yield self.get_smpp_helper()
deliver_sm_processor = smpp_helper.transport.deliver_sm_processor
session_manager = deliver_sm_processor.session_manager
yield session_manager.create_session(
vumi_session_identifier, ussd_code='*123#')
pdu = DeliverSM(1, short_message="", source_addr=source_addr)
pdu.add_optional_parameter('ussd_service_op', '81')
pdu.add_optional_parameter('user_message_reference',
session_identifier)
yield smpp_helper.handle_pdu(pdu)
[end] = yield self.tx_helper.wait_for_dispatched_inbound(1)
self.assertEqual(end['session_event'],
TransportUserMessage.SESSION_CLOSE)
示例15: test_submit_and_deliver_ussd_continue
# 需要导入模块: from smpp.pdu_builder import DeliverSM [as 别名]
# 或者: from smpp.pdu_builder.DeliverSM import add_optional_parameter [as 别名]
def test_submit_and_deliver_ussd_continue(self):
session = SessionInfo()
transport = yield self.get_transport()
deliver_sm_processor = transport.deliver_sm_processor
session_manager = deliver_sm_processor.session_manager
yield session_manager.create_session(
session.vumi_id, ussd_code='*123#')
yield self.tx_helper.make_dispatch_outbound(
"hello world", transport_type="ussd", transport_metadata={
'session_info': {
'session_identifier': session.sixdee_id,
}
}, to_addr=session.addr)
submit_sm_pdu = yield self.fake_smsc.await_pdu()
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'),
session.its_info)
# Server delivers a USSD message to the Client
pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!",
source_addr=session.addr)
# 0x12 is 'continue'
pdu.add_optional_parameter('ussd_service_op', '12')
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'], "reply!")
self.assertEqual(mess['transport_type'], "ussd")
self.assertEqual(mess['to_addr'], '*123#')
self.assertEqual(mess['session_event'],
TransportUserMessage.SESSION_RESUME)