Ejemplo n.º 1
0
 def test_start(self):
     port = choose_port()
     with master_context(port=port):
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port) as client:
             client.send(b"START %s p1 p2 p3 p4 p5 p6\n" % PLAYER_HOSTNAME)
             text = client.readline()
Ejemplo n.º 2
0
 def test_start(self):
     port = choose_port()
     with master_context(port=port):
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port) as client:
             client.send(b"START %s p1 p2 p3 p4 p5 p6\n" % PLAYER_HOSTNAME)
             text = client.readline()
Ejemplo n.º 3
0
 def test_exit(self):
     port = choose_port()
     with player_context(port) as proc:
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port, socket.SOCK_DGRAM) as client:
             client.send(b"QUIT\n")
         ret = proc.wait(5)
         self.assertEqual(ret, 0)
Ejemplo n.º 4
0
 def test_exit(self):
     port = choose_port()
     with player_context(port) as proc:
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port, socket.SOCK_DGRAM) as client:
             client.send(b"QUIT\n")
         ret = proc.wait(5)
         self.assertEqual(ret, 0)
Ejemplo n.º 5
0
 def test_start_wrong_host(self):
     port = choose_port()
     with master_context(port=port):
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port) as client:
             client.send(b"START definitely_nonexistent 1 2 3 4 5 6\n")
             line = client.recv(100)
             self.assertIn(b"ERROR", line)
Ejemplo n.º 6
0
    def test_wrong_command(self):
        port = choose_port()
        with master_context((str(port),), stderr=None, stdout=None):
            time.sleep(QUANTUM_SECONDS)
            with mock_client(port) as client:
                client.send(b"WRONG_COMMAND\n")
                line = client.recv(100)
                self.assertIn(b"ERROR", line)

                client.send(b"WRONG_COMMAND\n")
                line = client.recv(100)
                self.assertIn(b"ERROR", line)
Ejemplo n.º 7
0
 def test_start(self):
     port = choose_port()
     with master_context(port=port):
         time.sleep(QUANTUM_SECONDS)
         with mock_client(port) as client:
             client.send(b"START %s p1 p2 p3 p4 p5 p6\n" % PLAYER_HOSTNAME)
             text = client.recv(100)
             ok, num_str = text.strip().split()
             self.assertEqual(ok, b"OK")
             client_num = int(num_str)
             time.sleep(QUANTUM_SECONDS)
             # TODO: assert that ssh was executed with correct parameters
             # TODO: assert that the client is still running
             client.send(b"QUIT %d\n" % client_num)
             time.sleep(QUANTUM_SECONDS)
             ok = client.recv(100)
             self.assertEqual(ok, b"OK %d\n" % client_num)
Ejemplo n.º 8
0
def master_and_mock_client():
    port = choose_port()
    with master_context(port=port):
        time.sleep(QUANTUM_SECONDS)
        with mock_client(port) as client:
            yield client
Ejemplo n.º 9
0
def master_and_mock_client():
    port = choose_port()
    with master_context(port=port):
        time.sleep(QUANTUM_SECONDS)
        with mock_client(port) as client:
            yield client