Пример #1
0
    def test_invalid_replay(self):
        db_url = os.path.join('sqlite:///' + os.getcwd(), 'game.db')
        api = ChessAPI(db_url=db_url)
        session_id = api.create_game("hu4396", "pvp")["session_id"]
        ret = api.replay("hu", session_id, 0)
        self.assertEqual(ret["valid"], False)

        ret = api.replay("hu", session_id, -10)
        self.assertEqual(ret["valid"], False)

        ret = api.replay("hu", session_id, 1000)
        self.assertEqual(ret["valid"], False)
        ChessAPITestCase.remove_db_file()
Пример #2
0
 def test_replay_a_session(self):
     db_url = os.path.join('sqlite:///' + os.getcwd(), 'game.db')
     api = ChessAPI(db_url=db_url)
     session_id = api.create_game("hu4396", "pvp")["session_id"]
     api.update_game({"session_id": session_id, "src": Utility.encode(1, 0), "tar": Utility.encode(3, 0),
                      "role": "Pawn", "user": "******"})
     ret = api.replay("hu4396", session_id, 1)
     self.assertEqual(ret["history"], {'src': 'a2', 'tar': 'a4'})