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])
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 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())
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])
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])
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])