Exemple #1
0
 def test_disconnect(self):
     """
     should go through to hub.disconnect
     """
     shell = ShellProtocol()
     stop_d = defer.Deferred()
     shell.hub = FakeHub(disconnect=stop_d)
     sendLine = []
     shell.sendLine = sendLine.append
     
     shell.cmd_disconnect('tcp:8080')
 
     self.assertIn(('disconnect', 'tcp:8080'), shell.hub.called)
Exemple #2
0
 def test_build(self):
     s = ShellProtocol()
     build_response = {'uid': 'something'}
     s.hub = FakeHub(build=build_response)
     sendLine_called = []
     s.sendLine = sendLine_called.append
     
     s.cmd_build('project', 'version')
     
     self.assertNotEqual(sendLine_called, [],
         "Should have sent something back")
     self.assertTrue('something' in sendLine_called[0],
         "Should include the build request uid in the response")
     self.assertEqual(s.hub.called, [
         ('build', dict(project='project', version='version',
             test_path=None)),
     ])
Exemple #3
0
 def test_connect(self):
     """
     should go through to hub.connect
     """
     shell = ShellProtocol()
     client = defer.Deferred()
     shell.hub = FakeHub(connect=client)
     sendLine = []
     shell.sendLine = sendLine.append
     
     shell.cmd_connect('my endpoint')
     
     while sendLine:
         sendLine.pop()
     self.assertIn(('connect', 'my endpoint'), shell.hub.called)
     
     client.callback('foo')
     self.assertNotEqual(sendLine, [], "Once client connects, connectee "
                         "should be notified.")
Exemple #4
0
 def test_stop(self):
     """
     stop should go through to stopServer
     """
     shell = ShellProtocol()
     stop_d = defer.Deferred()
     shell.hub = FakeHub(stopServer=stop_d)
     sendLine = []
     shell.sendLine = sendLine.append
     
     shell.cmd_stop('tcp:8080')
     
     while sendLine:
         sendLine.pop()
     self.assertIn(('stopServer', 'tcp:8080'), shell.hub.called)
     
     stop_d.callback('foo')
     self.assertNotEqual(sendLine, [], "Once server stops, connectee "
                         "should be notified.")
Exemple #5
0
 def test_start(self):
     """
     start should go through to startServer
     """
     shell = ShellProtocol()
     factory = object()
     server = defer.Deferred()
     shell.hub = FakeHub(getPBServerFactory=factory, startServer=server)
     sendLine = []
     shell.sendLine = sendLine.append
     
     shell.cmd_start('tcp:8080')
     
     while sendLine:
         sendLine.pop()
     self.assertIn(('startServer', factory, 'tcp:8080'), shell.hub.called)
     
     server.callback('foo')
     self.assertNotEqual(sendLine, [], "Once server starts, connectee "
                         "should be notified.")