def test_ls(self): """ You can list the details of all pipes """ p = Plumber() p.addPipe('unix:foo', 'unix:foo2') p.addPipe('unix:bar', 'unix:bar2') r = list(p.ls()) expected = [tuple(['unix:bar']+list(x)) for x in p.pipeCommand('unix:bar', 'ls')] expected += [tuple(['unix:foo']+list(x)) for x in p.pipeCommand('unix:foo', 'ls')] self.assertEqual(r, expected)
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")