Esempio n. 1
0
 def test_resetDelay(self):
     initial_delay = ReconnectingClientService.initialDelay
     s = ReconnectingClientService(object(), object())
     s.delay, s.retries = initial_delay + 1, 5
     s.resetDelay()
     self.assertEqual(s.delay, initial_delay)
     self.assertEqual(s.retries, 0)
Esempio n. 2
0
 def test_clientConnected(self):
     reset = self.patch_reconnector('resetDelay')
     s = ReconnectingClientService(object(), object())
     p = object()
     s.clientConnected(p)
     self.assertIdentical(s._protocol, p)
     reset.assertCalledOnce()
Esempio n. 3
0
 def make_reconnector(self, **kw):
     e = ClientTestEndpoint()
     f = object()
     s = ReconnectingClientService(e, f)
     for key, value in kw.items():
         setattr(s, key, value)
     self.addCleanup(s.stopService)
     return s, e, f
Esempio n. 4
0
 def test_clientConnectionLost_while_stopping(self):
     retry = self.patch_reconnector('retry')
     s = ReconnectingClientService(object(), object())
     d = s._protocolStoppingDeferred = Deferred()
     s.clientConnectionLost(Failure(Exception()))
     self.assertIdentical(s._protocol, None)
     self.assertIdentical(s._protocolStoppingDeferred, None)
     retry.assertCalledOnce()
     self.assertTrue(d.called)
Esempio n. 5
0
    def setup_transport(self):
        warnings.warn(
            'This SMPP implementation is deprecated. Please use the '
            'implementations available in vumi.transports.smpp.'
            'smpp_transport instead.', category=DeprecationWarning)
        config = self.get_static_config()
        log.msg("Starting the SmppTransport for %s" % (
            config.twisted_endpoint))

        self.submit_sm_encoding = config.submit_sm_encoding
        self.submit_sm_data_coding = config.submit_sm_data_coding
        default_prefix = "%s@%s" % (config.system_id, config.transport_name)

        r_config = config.redis_manager
        r_prefix = config.split_bind_prefix or default_prefix

        redis = yield TxRedisManager.from_config(r_config)
        self.redis = redis.sub_manager(r_prefix)

        self.r_message_prefix = "message_json"
        self.throttled = False

        self.esme_callbacks = EsmeCallbacks(
            connect=self.esme_connected,
            disconnect=self.esme_disconnected,
            submit_sm_resp=self.submit_sm_resp,
            delivery_report=self.delivery_report,
            deliver_sm=self.deliver_sm)

        self._reconn_service = None
        if not hasattr(self, 'esme_client'):
            # start the Smpp transport (if we don't have one)
            self.factory = self.make_factory()
            self._reconn_service = ReconnectingClientService(
                config.twisted_endpoint, self.factory)
            self._reconn_service.startService()
Esempio n. 6
0
 def truteq_service_maker(endpoint, factory):
     return ReconnectingClientService(st_endpoint, factory)
Esempio n. 7
0
 def test_startService(self):
     retry = self.patch_reconnector('retry')
     s = ReconnectingClientService(object(), object())
     s.startService()
     self.assertTrue(s.continueTrying)
     retry.assertCalledOnce(delay=0.0)
Esempio n. 8
0
 def test_clientConnectionLost(self):
     retry = self.patch_reconnector('retry')
     s = ReconnectingClientService(object(), object())
     s.clientConnectionLost(Failure(Exception()))
     self.assertIdentical(s._protocol, None)
     retry.assertCalledOnce()