def test_chess_board_from_uuid(): """ Test a python-chess Board can be fully recovered from a Board model instance by providing the game uuid """ # Create board and make two moves chess_board = chess.Board() board_instance = Board.from_fen(chess_board.fen()) board_instance.save() first_move = "e2e4" second_move = "e7e5" services.move_piece(board_instance, first_move[:2], first_move[2:], chess_board=chess_board) services.move_piece(board_instance, second_move[:2], second_move[2:], chess_board=chess_board) new_chess_board = services.chess_board_from_uuid(board_instance.game_uuid) assert chess_board.ep_square == int(new_chess_board.ep_square) assert chess_board.castling_rights == int(new_chess_board.castling_rights) assert chess_board.turn == new_chess_board.turn assert chess_board.fullmove_number == new_chess_board.fullmove_number assert chess_board.halfmove_clock == new_chess_board.halfmove_clock assert chess_board.move_stack == new_chess_board.move_stack assert chess_board.fen() == new_chess_board.fen() assert chess_board.board_fen() == new_chess_board.board_fen()
def test_board_from_fen(): chess_board = chess.Board() fen = chess_board.fen() board = Board.from_fen(fen) assert board.ep_square is None assert board.halfmove_clock == 0 assert board.fullmove_number == 1 assert board.castling_xfen == "KQkq"
import pytest import chess from api import services from api.models import Board, Game, Result JWT_TOKEN = { "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU5NTIzMjMxMCwianRpIjoiMTViM2ZiZGNhODJlNDBiMDkyNTBiYzA5ZTlkODQwMmYiLCJ1c2VyX2lkIjoxfQ.3UZIhcS4X14zb9V7wRnf0G3TJ1f7G6UMijThokvOD_M", "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTk1MTQ1OTIyLCJqdGkiOiI1ODBjNmM3ZDcyNTk0NmJmOWJiNGY1YmMyMzcyMjY0MiIsInVzZXJfaWQiOjF9.44RKjIbKXmWqjzJA0TtpbnBTt3-3tAMxUP1EZDMJais", } CHESS_BOARD = chess.Board() BOARD_INSTANCE = Board.from_fen(CHESS_BOARD.fen()) @pytest.fixture def users(): user_one = services.User.objects.create( username="******", name="Walter Hartwell White", email="*****@*****.**", password="******", is_active=True, ) user_two = services.User.objects.create( username="******", name="Jesse Bruce Pinkman", email="*****@*****.**",