def test_ls(self): """ ls should call through to the plumber and return a dictionary ready for AMP """ c = Server(FakePlumber({ 'ls': [ ('foo', 'thing1', 0, True), ('bar', 'thing2', 1, False), ('bar', 'thing3', 12, True), ] })) r = c.ls() self.assertEqual(r['pipes'], [ { 'src': 'foo', 'dst': 'thing1', 'conns': 0, 'active': True, }, { 'src': 'bar', 'dst': 'thing2', 'conns': 1, 'active': False, }, { 'src': 'bar', 'dst': 'thing3', 'conns': 12, 'active': True, }, ])
def test_stop(self): """ Stop should mirror plumber.stop """ c = Server(FakePlumber()) c.stop() self.assertEqual(c.plumber.called, ['stop'])
def test_rmPipe(self): """ rmPipe should mirror plumber.rmPipe """ c = Server(FakePlumber()) c.rmPipe('foo') self.assertEqual(c.plumber.called, [ ('rmPipe', 'foo'), ])
def test_addPipe(self): """ addPipe should mirror plumber.addPipe """ c = Server(FakePlumber()) c.addPipe('foo', 'bar') self.assertEqual(c.plumber.called, [ ('addPipe', 'foo', 'bar'), ])
def test_switch(self): """ Switching should switch a Pipe's destination. """ c = Server(FakePlumber()) c.switch('foo', 'dst2') self.assertEqual(c.plumber.called, [ ('pipeCommand', 'foo', 'switch', ('dst2',), {}), ])
def test_wait(self): """ Wait should wait """ ret = defer.Deferred() c = Server(FakePlumber({ 'pipeCommand': ret, })) r = c.wait('foo') self.assertEqual(c.plumber.called, [ ('pipeCommand', 'foo', 'wait', (), {}), ]) self.assertFalse(r.called) ret.callback(None) def check(response): self.assertEqual(response, {}) return r.addCallback(check)