예제 #1
0
파일: test_hub.py 프로젝트: hagna/simplebb
    def test_gotRemoteRoot(self):
        """
        Should add remote to builder and observers, add self to remote builders
        and observers, start static info fetching.
        """
        hub = Hub()
        remote = FakeRemoteHub('foo')
        
        called = []
        def makeFake(name):
            def f(*args):
                called.append((name, args))
            return f
        
        hub.addBuilder = makeFake('addB')
        hub.addObserver = makeFake('addO')
        
        remote.addBuilder = makeFake('r_addB')
        remote.addObserver = makeFake('r_addO')
        remote.getStaticInfo = makeFake('r_getStaticInfo')

        hub.gotRemoteRoot(remote)
        
        self.assertEqual(set(called), set([
            ('addB', (remote,)),
            ('addO', (remote,)),
            ('r_addB', (hub,)),
            ('r_addO', (hub,)),
            ('r_getStaticInfo', ()),
        ]))
        self.assertEqual(remote.hub, hub)
예제 #2
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