1- from smpplib import consts
1+ from smpplib import consts , exceptions
22from smpplib .command import DeliverSM
33
4+ import pytest
5+
46
57def test_parse_deliver_sm ():
68 pdu = DeliverSM ('deliver_sm' )
@@ -21,3 +23,24 @@ def test_parse_deliver_sm():
2123 assert pdu .source_network_type == consts .SMPP_NETWORK_TYPE_GSM
2224 assert pdu .message_state == consts .SMPP_MESSAGE_STATE_DELIVERED
2325 assert pdu .user_message_reference is None
26+
27+
28+ def test_unrecognised_optional_parameters ():
29+ pdu = DeliverSM ("deliver_sm" , allow_unknown_opt_params = True )
30+ pdu .parse (b'\x00 \x00 \x00 \xa8 \x00 \x00 \x00 \x05 \x00 \x00 \x00 \x00 /p\xc6 '
31+ b'\x9a \x00 \x00 \x00 22549909028\x00 \x01 \x00 \x00 \x04 \x00 \x00 '
32+ b'\x00 \x00 \x00 \x00 \x00 \x00 iid:795920026 sub:001 dlvrd:001 '
33+ b'submit date:200319131913 done date:200319131913 stat:DELIVRD err:000 text:'
34+ b'\x14 \x03 \x00 \x07 (null)\x00 \x14 \x02 \x00 \x04 612\x00 '
35+ )
36+
37+ # This is only to avoid a breaking change, at some point the other behaviour
38+ # should become the default.
39+ with pytest .raises (exceptions .UnknownCommandError ):
40+ pdu2 = DeliverSM ("deliver_sm" )
41+ pdu2 .parse (b'\x00 \x00 \x00 \xa8 \x00 \x00 \x00 \x05 \x00 \x00 \x00 \x00 /p\xc6 '
42+ b'\x9a \x00 \x00 \x00 22549909028\x00 \x01 \x00 \x00 \x04 \x00 \x00 '
43+ b'\x00 \x00 \x00 \x00 \x00 \x00 iid:795920026 sub:001 dlvrd:001 '
44+ b'submit date:200319131913 done date:200319131913 stat:DELIVRD err:000 text:'
45+ b'\x14 \x03 \x00 \x07 (null)\x00 \x14 \x02 \x00 \x04 612\x00 '
46+ )
0 commit comments