Skip to content

Commit 61163a0

Browse files
committed
Merge pull request praekelt#13 from SimonStJG/validity-period-should-be-variable-length
The validity period for a submit_sm is variable length
2 parents 157bb66 + 61f01aa commit 61163a0

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

smpp/pdu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
{'name': 'protocol_id', 'min': 1, 'max': 1, 'var': False, 'type': 'integer', 'map': None},
7272
{'name': 'priority_flag', 'min': 1, 'max': 1, 'var': False, 'type': 'integer', 'map': None},
7373
{'name': 'schedule_delivery_time', 'min': 1, 'max': 17, 'var': False, 'type': 'string', 'map': None},
74-
{'name': 'validity_period', 'min': 1, 'max': 17, 'var': False, 'type': 'string', 'map': None},
74+
{'name': 'validity_period', 'min': 1, 'max': 17, 'var': True, 'type': 'string', 'map': None},
7575
{'name': 'registered_delivery', 'min': 1, 'max': 1, 'var': False, 'type': 'integer', 'map': None},
7676
{'name': 'replace_if_present_flag', 'min': 1, 'max': 1, 'var': False, 'type': 'integer', 'map': None},
7777
{'name': 'data_coding', 'min': 1, 'max': 1, 'var': False, 'type': 'integer', 'map': None},

tests.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,42 @@ def test_ignore_invalid_null_after_short_message_field(self):
381381
unpacked_dodgy_pdu = pdu.unpack_pdu(packed_pdu + '\x00')
382382
self.assertEqual(unpacked_pdu, unpacked_dodgy_pdu)
383383

384+
def test_validity_period(self):
385+
"""
386+
Should be able to pack and unpack a PDU with a valid validity_period.
387+
"""
388+
submit_sm = {
389+
'header': {
390+
'command_length': 67,
391+
'command_id': 'submit_sm',
392+
'command_status': 'ESME_ROK',
393+
'sequence_number': 0,
394+
},
395+
'body': {
396+
'mandatory_parameters': {
397+
'service_type': '',
398+
'source_addr_ton': 'international',
399+
'source_addr_npi': 'unknown',
400+
'source_addr': '',
401+
'dest_addr_ton': 'international',
402+
'dest_addr_npi': 'unknown',
403+
'destination_addr': '',
404+
'esm_class': 0,
405+
'protocol_id': 0,
406+
'priority_flag': 0,
407+
'schedule_delivery_time': '',
408+
'validity_period': '000001234567800R',
409+
'registered_delivery': 0,
410+
'replace_if_present_flag': 0,
411+
'data_coding': 0,
412+
'sm_default_msg_id': 0,
413+
'sm_length': 18,
414+
'short_message': 'Test Short Message',
415+
},
416+
},
417+
}
418+
self.assertEqual(pdu.unpack_pdu(pdu.pack_pdu(submit_sm)), submit_sm)
419+
384420

385421
class PduBuilderTestCase(unittest.TestCase):
386422
def test_submit_sm_message_too_long(self):

0 commit comments

Comments
 (0)