Skip to content

Commit

Permalink
Object to more than one multipart message mechanism in SMPP config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Thurgood committed Oct 22, 2013
1 parent f0c6c35 commit ac0992b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
45 changes: 45 additions & 0 deletions vumi/transports/smpp/tests/test_smpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

from twisted.internet.defer import Deferred, inlineCallbacks, succeed
from twisted.internet.task import Clock
from twisted.trial.unittest import TestCase
from smpp.pdu_builder import SubmitSMResp, DeliverSM

from vumi.config import ConfigError
from vumi.message import TransportUserMessage
from vumi.transports.smpp.clientserver.client import (
EsmeTransceiver, EsmeCallbacks)
Expand All @@ -18,6 +20,49 @@
from vumi.tests.utils import LogCatcher


class TestSmppTransportConfig(TestCase):
def required_config(self, config_params):
config = {
"transport_name": "sphex",
"twisted_endpoint": "tcp:host=localhost:port=0",
"system_id": "vumitest-vumitest-vumitest",
"password": "password",
}
config.update(config_params)
return config

def get_config(self, config_dict):
return SmppTransport.CONFIG_CLASS(config_dict)

def assert_config_error(self, config_dict):
try:
self.get_config(config_dict)
self.fail("ConfigError not raised.")
except ConfigError as err:
return err.message

def test_long_message_params(self):
self.get_config(self.required_config({}))
self.get_config(self.required_config({'send_long_messages': True}))
self.get_config(self.required_config({'send_multipart_sar': True}))
self.get_config(self.required_config({'send_multipart_udh': True}))
errmsg = self.assert_config_error(self.required_config({
'send_long_messages': True,
'send_multipart_sar': True,
}))
self.assertEqual(errmsg, (
"The following parameters are mutually exclusive: "
"send_long_messages, send_multipart_sar"))
errmsg = self.assert_config_error(self.required_config({
'send_long_messages': True,
'send_multipart_sar': True,
'send_multipart_udh': True,
}))
self.assertEqual(errmsg, (
"The following parameters are mutually exclusive: "
"send_long_messages, send_multipart_sar, send_multipart_udh"))


class SmppTransportTestCase(TransportTestCase):
transport_class = SmppTransport

Expand Down
9 changes: 9 additions & 0 deletions vumi/transports/smpp/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ class SmppTransportConfig(Transport.CONFIG_CLASS):
redis_manager = ConfigDict(
'How to connect to Redis', default={}, static=True)

def post_validate(self):
long_message_params = (
'send_long_messages', 'send_multipart_sar', 'send_multipart_udh')
set_params = [p for p in long_message_params if getattr(self, p)]
if len(set_params) > 1:
params = ', '.join(set_params)
self.raise_config_error(
"The following parameters are mutually exclusive: %s" % params)


class SmppTransport(Transport):
"""
Expand Down

0 comments on commit ac0992b

Please sign in to comment.