def test__create_channel_sets_transport_kwarg(self): # if send_name is a transport, it makes sure that kwarg is passed in to node's channel (and therefore the channel) class FakeSendName(NameTrio, BaseTransport): pass fn = FakeSendName() ep = SendingBaseEndpoint(node=Mock(spec=NodeB), to_name=fn) ch = ep._create_channel() self.assertIn('transport', ep.node.channel.call_args[1]) self.assertIn(fn, ep.node.channel.call_args[1].itervalues())
def test_init_with_to_name_namepair(self): class MyNameTrio(NameTrio): def __init__(self): self._exchange = sentinel.my_exchange self._queue = sentinel.my_queue ep = SendingBaseEndpoint(to_name=MyNameTrio()) self.assertEquals(ep._send_name.exchange, sentinel.my_exchange) self.assertEquals(ep._send_name.queue, sentinel.my_queue)
def test_create_endpoint_with_tuple(self): ep = SendingBaseEndpoint(node=Mock(spec=NodeB)) e = ep.create_endpoint(to_name=(sentinel.ex, sentinel.name)) self.assertIsInstance(e.channel.connect.call_args[0][0], NameTrio)
def test_create_endpoint_calls_connect(self): np = NameTrio(sentinel.xp, sentinel.queue) ep = SendingBaseEndpoint(node=Mock(spec=NodeB), to_name=np) e = ep.create_endpoint() e.channel.connect.assert_called_once_with(np)
def test_init_with_old_name_gives_warn(self, mocklog): ep = SendingBaseEndpoint(name=(sentinel.xp, sentinel.rkey)) self.assertEquals(ep._send_name.exchange, sentinel.xp) self.assertEquals(ep._send_name.queue, sentinel.rkey) self.assertTrue(mocklog.warn.called)
def test_init_with_to_name(self): ep = SendingBaseEndpoint(to_name=(sentinel.xp, sentinel.rkey)) self.assertEquals(ep._send_name.exchange, sentinel.xp) self.assertEquals(ep._send_name.queue, sentinel.rkey)
def test_init(self): ep = SendingBaseEndpoint(node=sentinel.node) self.assertEquals(ep.node, sentinel.node) self.assertIsInstance(ep._send_name, NameTrio)