def test_getPipe(self): """ You can get the Pipe itself using the src endpoint as a key. """ listen = 'unix:'+self.mktemp() connect = 'unix:path='+self.mktemp() p = Plumber() p.addPipe(listen, connect) pipe = p.getPipe(listen) self.assertTrue(isinstance(pipe, Pipe)) self.assertEqual(pipe, list(p.pipe_services)[0].factory)
def test_pipeCommand(self): """ You can execute things on the Pipe with a key """ listen = 'unix:'+self.mktemp() connect = 'unix:path='+self.mktemp() p = Plumber() p.addPipe(listen, connect) pipe = p.getPipe(listen) called = [] def fake(*a, **kw): called.append((a, kw)) return 'result' pipe.foo = fake r = p.pipeCommand(listen, 'foo', 'arg1', 'arg2', kw1='foo', kw2='bar') self.assertEqual(r, 'result', "Should return whatever the Pipe's " "method returned") self.assertEqual(called, [ (('arg1', 'arg2'), {'kw1':'foo', 'kw2':'bar'}), ], "Should have passed all the appropriate args through")