Skip to content

Commit

Permalink
Assert on the specific PDU short messages created by the Mica UDH pro…
Browse files Browse the repository at this point in the history
…cessor.
  • Loading branch information
hodgestar committed Feb 24, 2015
1 parent 3a77683 commit d89be4c
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions vumi/transports/smpp/tests/test_mica.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
from vumi.message import TransportUserMessage

from vumi.transports.smpp.pdu_utils import (
command_id, seq_no, pdu_tlv)
command_id, seq_no, pdu_tlv, short_message)
from vumi.transports.smpp.tests.test_smpp_transport import (
SmppTransportTestCase)
from vumi.transports.smpp.smpp_transport import (
SmppTransceiverTransport)
from vumi.transports.smpp.processors.mica import make_vumi_session_identifier
from vumi.transports.smpp.pdu_utils import short_message


class MicaProcessorTestCase(SmppTransportTestCase):
Expand Down Expand Up @@ -43,6 +42,14 @@ def setUp(self):
}
}

def assert_udh_parts(self, pdus, texts, encoding):
pdu_header = lambda pdu: short_message(pdu)[:6]
pdu_text = lambda pdu: short_message(pdu)[6:].decode(encoding)
udh_header = lambda i: '\x05\x00\x03\x03\x07' + chr(i)
self.assertEqual(
[(pdu_header(pdu), pdu_text(pdu)) for pdu in pdus],
[(udh_header(i + 1), text) for i, text in enumerate(texts)])

@inlineCallbacks
def test_submit_sm_multipart_udh_ucs2(self):
message = (
Expand All @@ -58,6 +65,21 @@ def test_submit_sm_multipart_udh_ucs2(self):
smpp_helper = yield self.get_smpp_helper()
yield self.tx_helper.make_dispatch_outbound(message, to_addr='msisdn')
pdus = yield smpp_helper.wait_for_pdus(7)
self.assert_udh_parts(pdus, [
"A cup is a small, open container used for carrying and drinking"
" d",
"rinks. It may be made of wood, plastic, glass, clay, metal,"
" stone",
", china or other materials, and may have a stem, handles or"
" other",
" adornments. Cups are used for drinking across a wide range of"
" cu",
"ltures and social classes, and different styles of cups may be"
" us",
"ed for different liquids or in different situations. Cups have"
" be",
"en used for thousands of years for the ...Reply 1 for more",
], encoding='utf-16be') # utf-16be is close enough to UCS2
for pdu in pdus:
self.assertTrue(len(short_message(pdu)) < 140)

Expand Down

0 comments on commit d89be4c

Please sign in to comment.