def test_remote_remBuilder(self): """ Should wrap the remote then call remBuilder """ h = Hub() h.remoteHubFactory = FakeRemoteHub called = [] h.remBuilder = called.append h.remote_remBuilder('foo') self.assertEqual(len(called), 1) r = called[0] self.assertTrue(isinstance(r, FakeRemoteHub)) self.assertEqual(r.original, 'foo')
def test_remote_remObserver(self): """ Should wrap the remote and call removeObserver """ h = Hub() h.remoteHubFactory = FakeRemoteHub called = [] h.remObserver = called.append h.remote_remObserver('foo') self.assertEqual(len(called), 1) observer = called[0] self.assertTrue(isinstance(observer, FakeRemoteHub)) self.assertEqual(observer.original, 'foo')
def test_connect(self): """ You can connect to other servers. This is functionalish """ server = Hub() client = Hub() called = [] client.remoteHubFactory = lambda x: 'foo' client.gotRemoteRoot = called.append server.startServer(server.getPBServerFactory(), 'tcp:10999') def check(r): self.assertEqual(called, ['foo'], "Should have called .gotRemoteRoot with wrapped remote") return r d = client.connect('tcp:host=127.0.0.1:port=10999') d.addCallback(check) d.addCallback(lambda x: client.disconnect( 'tcp:host=127.0.0.1:port=10999')) d.addCallback(lambda x: server.stopServer('tcp:10999')) return d