コード例 #1
0
ファイル: test_hub.py プロジェクト: hagna/simplebb
 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')
コード例 #2
0
ファイル: test_hub.py プロジェクト: hagna/simplebb
 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')
コード例 #3
0
ファイル: test_hub.py プロジェクト: hagna/simplebb
    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