def test_instantiation_extended(self): client_config = ClientConfig.from_config({ "host": 'localhost', "port": 2775, "system_id": 'test_system', "password": '******', "system_type": "some_type", "interface_version": "34", "dest_addr_ton": 1, "dest_addr_npi": 1, "registered_delivery": 1, "smpp_bind_timeout": 33, "some_garbage_param_that_should_not_be_here": "foo", }) expected_config = ClientConfig( host='localhost', port=2775, system_id='test_system', password='******', system_type="some_type", interface_version="34", dest_addr_ton=1, dest_addr_npi=1, registered_delivery=1, smpp_bind_timeout=33, ) self.assertEqual(client_config, expected_config)
def test_string_values_are_converted(self): client_config = ClientConfig.from_config({ "host": 'localhost', "port": 2775, "system_id": 'test_system', "password": '******', "dest_addr_ton": "1", "dest_addr_npi": "1", "registered_delivery": "1", "smpp_bind_timeout": "33", "initial_reconnect_delay": "1.5", }) self.assertEqual(client_config.dest_addr_ton, 1) self.assertEqual(client_config.dest_addr_npi, 1) self.assertEqual(client_config.registered_delivery, 1) self.assertEqual(client_config.smpp_bind_timeout, 33) self.assertEqual(client_config.initial_reconnect_delay, 1.5)
def get_esme(self, **callbacks): config = ClientConfig(host="127.0.0.1", port="0", system_id="1234", password="******") esme_callbacks = EsmeCallbacks(**callbacks) esme = FakeEsmeTransceiver(config, FakeRedis(), esme_callbacks) return esme
def test_minimal_instantiation(self): config1 = ClientConfig( host='localhost', port=2775, system_id='test_system', password='******', ) config2 = ClientConfig( host='localhost', port=2775, system_id='test_system', password='******', system_type="", interface_version="34", dest_addr_ton=0, dest_addr_npi=0, registered_delivery=0, ) self.assertEqual(config1, config2)
def setUp(self): self.client_config = ClientConfig( host='localhost', port=2775, system_id='test_system', password='******', ) self.kvs = None self.esme_callbacks = None self.esme = ESME(self.client_config, self.kvs, self.esme_callbacks)
def test_sequence_rollover(self): config = ClientConfig(host="127.0.0.1", port="0", system_id="1234", password="******") esme = FakeEsmeTransceiver(config, FakeRedis(), None) self.assertEqual(1, esme.get_seq()) esme.get_next_seq() self.assertEqual(2, esme.get_seq()) esme.set_seq(4004004004) self.assertEqual(4004004004, esme.get_seq()) esme.get_next_seq() self.assertEqual(1, esme.get_seq())
def setUp(self): super(FakeRedisRespTestCase, self).setUp() self.config = { "TRANSPORT_NAME": "redis_testing_transport", "system_id": "vumitest-vumitest-vumitest", "host": "host", "port": "port", "password": "******", } self.vumi_options = { "vhost": "develop", } self.clientConfig = ClientConfig( system_id=self.config['system_id'], host=self.config['host'], port=self.config['port'], password=self.config['password'], ) # hack a lot of transport setup self.transport = yield self.get_transport(self.config, start=False) self.transport.r_server = FakeRedis() self.esme_callbacks = EsmeCallbacks( connect=lambda: None, disconnect=lambda: None, submit_sm_resp=self.transport.submit_sm_resp, delivery_report=lambda: None, deliver_sm=lambda: None) self.esme = RedisTestEsmeTransceiver( self.clientConfig, self.transport.r_server, self.esme_callbacks) self.esme.state = 'BOUND_TRX' self.transport.esme_client = self.esme yield self.transport.startWorker() self.transport.esme_connected(self.esme)
def validate_config(self): self.client_config = ClientConfig.from_config(self.config)