Exemple #1
0
    def test_stop(self):
        request = self.mock_request("stop")

        handler = s.TCPHandler(request, None, self.server)
        handler.handle()

        self.server.q.put.assert_called_with({"message": "stop", "data": {}})
        request.sendall.assert_called_with(b"OK")
Exemple #2
0
    def test_invalid_b(self):
        request = self.mock_request("p10s999")

        handler = s.TCPHandler(request, None, self.server)
        handler.handle()

        self.server.q.put.assert_not_called()
        request.sendall.assert_called_with(b"ERR")
Exemple #3
0
    def test_lanechange_invalid_value(self):
        request = self.mock_request("p2l2")

        handler = s.TCPHandler(request, None, self.server)
        handler.handle()

        self.server.q.put.assert_not_called()
        request.sendall.assert_called_with(b"ERR")
Exemple #4
0
    def test_speedinc_invalid_symbol(self):
        request = self.mock_request("p2s*")

        handler = s.TCPHandler(request, None, self.server)
        handler.handle()

        self.server.q.put.assert_not_called()
        request.sendall.assert_called_with(b"ERR")
Exemple #5
0
    def test_speed_c(self):
        request = self.mock_request("p3s9")

        handler = s.TCPHandler(request, None, self.server)
        handler.handle()

        self.server.q.put.assert_called_with({
            "message": "speed",
            "data": {
                "player": 3,
                "value": 9,
            }
        })
        request.sendall.assert_called_with(b"OK")
Exemple #6
0
    def test_lanechange_b(self):
        request = self.mock_request("p2l0")

        handler = s.TCPHandler(request, None, self.server)
        handler.handle()

        self.server.q.put.assert_called_with({
            "message": "lanechange",
            "data": {
                "player": 2,
                "value": False,
            }
        })
        request.sendall.assert_called_with(b"OK")