Пример #1
0
class TestToAddrRouter(TestCase, MessageMakerMixIn):
    def setUp(self):
        self.config = {
            'transport_names': ['transport1'],
            'exposed_names': ['app1', 'app2'],
            'toaddr_mappings': {
                'app1': 'to:.*:1',
                'app2': 'to:app2',
                },
            }
        self.dispatcher = DummyDispatcher(self.config)
        self.router = ToAddrRouter(self.dispatcher, self.config)

    def test_dispatch_inbound_message(self):
        msg = self.mkmsg_in(to_addr='to:foo:1', transport_name='transport1')
        self.router.dispatch_inbound_message(msg)
        publishers = self.dispatcher.exposed_publisher
        self.assertEqual(publishers['app1'].msgs, [msg])
        self.assertEqual(publishers['app2'].msgs, [])

    def test_dispatch_outbound_message(self):
        msg = self.mkmsg_out(transport_name='transport1')
        self.router.dispatch_outbound_message(msg)
        publishers = self.dispatcher.transport_publisher
        self.assertEqual(publishers['transport1'].msgs, [msg])
Пример #2
0
 def setUp(self):
     self.config = {
         'transport_names': ['transport1'],
         'exposed_names': ['app1', 'app2'],
         'toaddr_mappings': {
             'app1': 'to:.*:1',
             'app2': 'to:app2',
         },
     }
     self.dispatcher = DummyDispatcher(self.config)
     self.router = ToAddrRouter(self.dispatcher, self.config)
Пример #3
0
 def setUp(self):
     self.config = {
         'transport_names': ['transport1'],
         'exposed_names': ['app1', 'app2'],
         'toaddr_mappings': {
             'app1': 'to:.*:1',
             'app2': 'to:app2',
         },
     }
     self.dispatcher = DummyDispatcher(self.config)
     self.router = ToAddrRouter(self.dispatcher, self.config)
     yield self.router.setup_routing()
     self.msg_helper = self.add_helper(MessageHelper())
Пример #4
0
 def setUp(self):
     self.config = {
         'transport_names': ['transport1'],
         'exposed_names': ['app1', 'app2'],
         'toaddr_mappings': {
             'app1': 'to:.*:1',
             'app2': 'to:app2',
             },
         }
     self.dispatcher = DummyDispatcher(self.config)
     self.router = ToAddrRouter(self.dispatcher, self.config)
Пример #5
0
class TestToAddrRouter(TestCase, MessageMakerMixIn):
    def setUp(self):
        self.config = {
            'transport_names': ['transport1'],
            'exposed_names': ['app1', 'app2'],
            'toaddr_mappings': {
                'app1': 'to:.*:1',
                'app2': 'to:app2',
            },
        }
        self.dispatcher = DummyDispatcher(self.config)
        self.router = ToAddrRouter(self.dispatcher, self.config)

    def test_dispatch_inbound_message(self):
        msg = self.mkmsg_in(to_addr='to:foo:1', transport_name='transport1')
        self.router.dispatch_inbound_message(msg)
        publishers = self.dispatcher.exposed_publisher
        self.assertEqual(publishers['app1'].msgs, [msg])
        self.assertEqual(publishers['app2'].msgs, [])

    def test_dispatch_outbound_message(self):
        msg = self.mkmsg_out(transport_name='transport1')
        self.router.dispatch_outbound_message(msg)
        publishers = self.dispatcher.transport_publisher
        self.assertEqual(publishers['transport1'].msgs, [msg])

        self.dispatcher.transport_publisher['transport1'].clear()
        self.config['transport_mappings'] = {
            'upstream1': 'transport1',
        }

        msg = self.mkmsg_out(transport_name='upstream1')
        self.router.dispatch_outbound_message(msg)
        publishers = self.dispatcher.transport_publisher
        self.assertEqual(publishers['transport1'].msgs, [msg])
Пример #6
0
 def setUp(self):
     self.config = {
         'transport_names': ['transport1'],
         'exposed_names': ['app1', 'app2'],
         'toaddr_mappings': {
             'app1': 'to:.*:1',
             'app2': 'to:app2',
             },
         }
     self.dispatcher = DummyDispatcher(self.config)
     self.router = ToAddrRouter(self.dispatcher, self.config)
     yield self.router.setup_routing()
     self.msg_helper = self.add_helper(MessageHelper())
Пример #7
0
class TestToAddrRouter(VumiTestCase):
    @inlineCallbacks
    def setUp(self):
        self.config = {
            'transport_names': ['transport1'],
            'exposed_names': ['app1', 'app2'],
            'toaddr_mappings': {
                'app1': 'to:.*:1',
                'app2': 'to:app2',
            },
        }
        self.dispatcher = DummyDispatcher(self.config)
        self.router = ToAddrRouter(self.dispatcher, self.config)
        yield self.router.setup_routing()
        self.msg_helper = self.add_helper(MessageHelper())

    def test_dispatch_inbound_message(self):
        msg = self.msg_helper.make_inbound("1",
                                           to_addr='to:foo:1',
                                           transport_name='transport1')
        self.router.dispatch_inbound_message(msg)
        publishers = self.dispatcher.exposed_publisher
        self.assertEqual(publishers['app1'].msgs, [msg])
        self.assertEqual(publishers['app2'].msgs, [])

    def test_dispatch_outbound_message(self):
        msg = self.msg_helper.make_outbound("out", transport_name='transport1')
        self.router.dispatch_outbound_message(msg)
        publishers = self.dispatcher.transport_publisher
        self.assertEqual(publishers['transport1'].msgs, [msg])

        self.dispatcher.transport_publisher['transport1'].clear()
        self.config['transport_mappings'] = {
            'upstream1': 'transport1',
        }

        msg = self.msg_helper.make_outbound("out", transport_name='upstream1')
        self.router.dispatch_outbound_message(msg)
        publishers = self.dispatcher.transport_publisher
        self.assertEqual(publishers['transport1'].msgs, [msg])
Пример #8
0
class TestToAddrRouter(VumiTestCase):

    @inlineCallbacks
    def setUp(self):
        self.config = {
            'transport_names': ['transport1'],
            'exposed_names': ['app1', 'app2'],
            'toaddr_mappings': {
                'app1': 'to:.*:1',
                'app2': 'to:app2',
                },
            }
        self.dispatcher = DummyDispatcher(self.config)
        self.router = ToAddrRouter(self.dispatcher, self.config)
        yield self.router.setup_routing()
        self.msg_helper = self.add_helper(MessageHelper())

    def test_dispatch_inbound_message(self):
        msg = self.msg_helper.make_inbound(
            "1", to_addr='to:foo:1', transport_name='transport1')
        self.router.dispatch_inbound_message(msg)
        publishers = self.dispatcher.exposed_publisher
        self.assertEqual(publishers['app1'].msgs, [msg])
        self.assertEqual(publishers['app2'].msgs, [])

    def test_dispatch_outbound_message(self):
        msg = self.msg_helper.make_outbound("out", transport_name='transport1')
        self.router.dispatch_outbound_message(msg)
        publishers = self.dispatcher.transport_publisher
        self.assertEqual(publishers['transport1'].msgs, [msg])

        self.dispatcher.transport_publisher['transport1'].clear()
        self.config['transport_mappings'] = {
            'upstream1': 'transport1',
            }

        msg = self.msg_helper.make_outbound("out", transport_name='upstream1')
        self.router.dispatch_outbound_message(msg)
        publishers = self.dispatcher.transport_publisher
        self.assertEqual(publishers['transport1'].msgs, [msg])