Exemple #1
0
 def test_setup_sync(self):
     """
     DispatcherHelper.setup() should return ``None``, not a Deferred.
     """
     msg_helper = DispatcherHelper(None)
     self.add_cleanup(msg_helper.cleanup)
     self.assertEqual(msg_helper.setup(), None)
Exemple #2
0
 def test_get_connector_helper(self):
     """
     .get_connector_helper() should return a DispatcherConnectorHelper
     instance for the provided connector name.
     """
     disp_helper = DispatcherHelper(None)
     dc_helper = disp_helper.get_connector_helper('barconn')
     self.assertEqual(dc_helper.msg_helper, disp_helper.msg_helper)
     self.assertEqual(dc_helper.worker_helper._connector_name, 'barconn')
     self.assertEqual(
         dc_helper.worker_helper.broker, disp_helper.worker_helper.broker)
Exemple #3
0
 def test_cleanup(self):
     """
     DispatcherHelper.cleanup() should call .cleanup() on its
     PersistenceHelper and WorkerHelper.
     """
     disp_helper = DispatcherHelper(None)
     disp_helper.persistence_helper = FakeCleanupCheckHelper()
     disp_helper.worker_helper = FakeCleanupCheckHelper()
     self.assertEqual(disp_helper.persistence_helper.cleaned_up, False)
     self.assertEqual(disp_helper.worker_helper.cleaned_up, False)
     success_result_of(disp_helper.cleanup())
     self.assertEqual(disp_helper.persistence_helper.cleaned_up, True)
     self.assertEqual(disp_helper.worker_helper.cleaned_up, True)
Exemple #4
0
 def setUp(self):
     self.disp_helper = self.add_helper(
         DispatcherHelper(BaseDispatchWorker))
     self.dispatcher = yield self.disp_helper.get_dispatcher({
         'dispatcher_name':
         'user_group_dispatcher',
         'router_class':
         'vumi.dispatchers.base.UserGroupingRouter',
         'transport_names': [
             'transport1',
         ],
         'exposed_names': [
             'app1',
             'app2',
         ],
         'group_mappings': {
             'group1': 'app1',
             'group2': 'app2',
         },
         'transport_mappings': {
             'upstream1': 'transport1',
         },
     })
     self.router = self.dispatcher._router
     yield self.router._redis_d
     self.redis = self.router.redis
     yield self.redis._purge_all()  # just in case
Exemple #5
0
 def test_all_params(self):
     """
     DispatcherHelper should pass use_riak to its PersistenceHelper and all
     other params to its MessageHelper.
     """
     fake_disp_class = object()
     disp_helper = DispatcherHelper(
         fake_disp_class, use_riak=True, transport_addr='Obs station')
     self.assertEqual(disp_helper.persistence_helper.use_riak, True)
     self.assertEqual(disp_helper.msg_helper.transport_addr, 'Obs station')
Exemple #6
0
 def test_get_application_different_class(self):
     """
     .get_dispatcher() should return an instance of the specified worker
     class if one is provided.
     """
     disp_helper = self.add_helper(DispatcherHelper(Dispatcher))
     app = yield disp_helper.get_dispatcher({
         'receive_inbound_connectors': [],
         'receive_outbound_connectors': [],
     }, cls=RunningCheckDispatcher)
     self.assertIsInstance(app, RunningCheckDispatcher)
Exemple #7
0
 def test_get_dispatcher_defaults(self):
     """
     .get_dispatcher() should return a started dispatcher.
     """
     disp_helper = self.add_helper(DispatcherHelper(RunningCheckDispatcher))
     app = yield disp_helper.get_dispatcher({
         'receive_inbound_connectors': [],
         'receive_outbound_connectors': [],
     })
     self.assertIsInstance(app, RunningCheckDispatcher)
     self.assertEqual(app.disp_worker_running, True)
Exemple #8
0
 def test_get_dispatcher_no_start(self):
     """
     .get_dispatcher() should return an unstarted dispatcher if passed
     ``start=False``.
     """
     disp_helper = self.add_helper(DispatcherHelper(RunningCheckDispatcher))
     app = yield disp_helper.get_dispatcher({
         'receive_inbound_connectors': [],
         'receive_outbound_connectors': [],
     }, start=False)
     self.assertIsInstance(app, RunningCheckDispatcher)
     self.assertEqual(app.disp_worker_running, False)
Exemple #9
0
 def setUp(self):
     self.disp_helper = self.add_helper(
         DispatcherHelper(BaseDispatchWorker))
     self.worker = yield self.disp_helper.get_worker(
         BaseDispatchWorker, {
             "transport_names": [
                 "transport1",
                 "transport2",
             ],
             "exposed_names": [],
             "router_class":
             "vumi.dispatchers.base.TransportToTransportRouter",
             "route_mappings": {
                 "transport1": ["transport2"],
             },
         })
Exemple #10
0
 def test_defaults(self):
     """
     DispatcherHelper instances should have the expected parameter defaults.
     """
     fake_disp_class = object()
     disp_helper = DispatcherHelper(fake_disp_class)
     self.assertEqual(disp_helper.dispatcher_class, fake_disp_class)
     self.assertIsInstance(
         disp_helper.persistence_helper, PersistenceHelper)
     self.assertIsInstance(disp_helper.msg_helper, MessageHelper)
     self.assertIsInstance(disp_helper.worker_helper, WorkerHelper)
     dispatch_helper = disp_helper.dispatch_helper
     self.assertIsInstance(dispatch_helper, MessageDispatchHelper)
     self.assertEqual(dispatch_helper.msg_helper, disp_helper.msg_helper)
     self.assertEqual(
         dispatch_helper.worker_helper, disp_helper.worker_helper)
     self.assertEqual(disp_helper.persistence_helper.use_riak, False)
Exemple #11
0
 def setUp(self):
     self.disp_helper = self.add_helper(
         DispatcherHelper(BaseDispatchWorker))
     self.dispatcher = yield self.disp_helper.get_dispatcher({
         'dispatcher_name':
         'redirect_outbound_dispatcher',
         'router_class':
         'vumi.dispatchers.base.RedirectOutboundRouter',
         'transport_names': ['smpp_rx_transport', 'smpp_tx_transport'],
         'exposed_names': ['upstream'],
         'redirect_outbound': {
             'upstream': 'smpp_tx_transport',
         },
         'redirect_inbound': {
             'smpp_tx_transport': 'upstream',
             'smpp_rx_transport': 'upstream',
         },
     })
     self.router = self.dispatcher._router
Exemple #12
0
 def setUp(self):
     self.disp_helper = self.add_helper(
         DispatcherHelper(BaseDispatchWorker))
     self.dispatcher = yield self.disp_helper.get_dispatcher({
         'dispatcher_name':
         'redirect_outbound_dispatcher',
         'router_class':
         'vumi.dispatchers.base.RedirectOutboundRouter',
         'transport_names': ['transport1', 'transport2'],
         'exposed_names': ['app1', 'app2'],
         'redirect_outbound': {
             'app1': 'transport1',
             'app2': 'transport2',
         },
         'redirect_inbound': {
             'transport1': 'app1',
             'transport2': 'app2',
         }
     })
     self.router = self.dispatcher._router
Exemple #13
0
 def setUp(self):
     self.disp_helper = self.add_helper(
         DispatcherHelper(BaseDispatchWorker))
     self.dispatcher = yield self.disp_helper.get_dispatcher({
         'dispatcher_name':
         'keyword_dispatcher',
         'router_class':
         'vumi.dispatchers.base.ContentKeywordRouter',
         'transport_names': ['transport1', 'transport2'],
         'transport_mappings': {
             'shortcode1': 'transport1',
             'shortcode2': 'transport2',
         },
         'exposed_names': ['app1', 'app2', 'app3', 'fallback_app'],
         'rules': [{
             'app': 'app1',
             'keyword': 'KEYWORD1',
             'to_addr': '8181',
             'prefix': '+256',
         }, {
             'app': 'app2',
             'keyword': 'KEYWORD2',
         }],
         'keyword_mappings': {
             'app2': 'KEYWORD3',
             'app3': 'KEYWORD1',
         },
         'fallback_application':
         'fallback_app',
         'expire_routing_memory':
         '3',
     })
     self.router = self.dispatcher._router
     yield self.router._redis_d
     self.add_cleanup(self.router.session_manager.stop)
     self.redis = self.router.redis
     yield self.redis._purge_all()  # just in case
Exemple #14
0
 def setUp(self):
     self.disp_helper = self.add_helper(
         DispatcherHelper(BaseDispatchWorker))
Exemple #15
0
 def setUp(self):
     self.disp_helper = self.add_helper(
         DispatcherHelper(RoutingTableDispatcher))
Exemple #16
0
 def test_implements_IHelper(self):
     """
     DispatcherHelper instances should provide the IHelper interface.
     """
     self.assertTrue(IHelper.providedBy(DispatcherHelper(None)))