Skip to content

Commit

Permalink
Merge 5af8de1 into 2069b09
Browse files Browse the repository at this point in the history
  • Loading branch information
jerith committed Oct 10, 2013
2 parents 2069b09 + 5af8de1 commit f459253
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
15 changes: 14 additions & 1 deletion vumi/transports/smpp/clientserver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@
from smpp.pdu import unpack_pdu
from smpp.pdu_builder import (
BindTransceiver, BindTransmitter, BindReceiver, DeliverSMResp, SubmitSM,
EnquireLink, EnquireLinkResp, QuerySM)
EnquireLink, EnquireLinkResp, QuerySM, PDU)
from smpp.pdu_inspector import (
MultipartMessage, detect_multipart, multipart_key)

from vumi import log


class UnbindResp(PDU):
# pdu_builder doesn't have one of these yet.
def __init__(self, sequence_number, **kwargs):
super(UnbindResp, self).__init__(
'unbind_resp', 'ESME_ROK', sequence_number, **kwargs)


def unpacked_pdu_opts(unpacked_pdu):
pdu_opts = {}
for opt in unpacked_pdu['body'].get('optional_parameters', []):
Expand Down Expand Up @@ -218,6 +225,12 @@ def cancel_drop_connection_call(self):
self._lose_conn.cancel()
self._lose_conn = None

@inlineCallbacks
def handle_unbind(self, pdu):
yield self.send_pdu(UnbindResp(
sequence_number=pdu['header']['sequence_number']))
self.transport.loseConnection()

@inlineCallbacks
def handle_bind_transceiver_resp(self, pdu):
if pdu['header']['command_status'] == 'ESME_ROK':
Expand Down
10 changes: 9 additions & 1 deletion vumi/transports/smpp/clientserver/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from twisted.trial import unittest
from twisted.internet.task import Clock
from twisted.internet.defer import inlineCallbacks, returnValue
from smpp.pdu_builder import DeliverSM, BindTransceiverResp
from smpp.pdu_builder import DeliverSM, BindTransceiverResp, Unbind
from smpp.pdu import unpack_pdu

from vumi.tests.utils import LogCatcher, PersistenceMixin
Expand Down Expand Up @@ -169,6 +169,14 @@ def test_sequence_rollover(self):
self.assertEqual(0xFFFF0001, (yield esme.get_next_seq()))
self.assertEqual(1, (yield esme.get_next_seq()))

@inlineCallbacks
def test_unbind(self):
esme = yield self.get_esme()

yield esme.handle_data(Unbind(1).get_bin())

self.assertEqual(False, esme.transport.connected)


class EsmeTransmitterMixin(EsmeGenericMixin):
"""Transmitter-side tests."""
Expand Down

0 comments on commit f459253

Please sign in to comment.