Skip to content

Commit

Permalink
fix tests after renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentAuriau committed Nov 4, 2023
1 parent beb8024 commit cff7c53
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
28 changes: 12 additions & 16 deletions tests/prev_engine_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import sys

sys.path.append("pyalapin")

import pyalapin.engine.engine as engine
import pyalapin.engine.move as move
import time
Expand All @@ -10,7 +6,7 @@


def test_working_castling():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
print("///", game.board.all_material["black"]["alive"]["king"][0].has_moved)
game.move_from_coordinates(game.player2, 6, 4, 4, 4)
Expand Down Expand Up @@ -45,7 +41,7 @@ def test_working_castling():


def test_failing_castling():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 4, 4, 4)
game.move_from_coordinates(game.player1, 0, 5, 3, 2)
Expand All @@ -64,13 +60,13 @@ def test_failing_castling():


def test_blocked_moves():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 7, 0, 5, 0)


def test_en_passant():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 0, 5, 0)
game.move_from_coordinates(game.player1, 3, 4, 4, 4)
Expand All @@ -79,7 +75,7 @@ def test_en_passant():


def test_end_game():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 4, 5)
game.move_from_coordinates(game.player1, 0, 3, 4, 7)
Expand All @@ -88,7 +84,7 @@ def test_end_game():


def test_pawn_transformation():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 4, 5)
game.move_from_coordinates(game.player1, 0, 3, 4, 7)
Expand All @@ -102,15 +98,15 @@ def test_pawn_transformation():


def check_unchecking():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 4, 5)
game.move_from_coordinates(game.player1, 0, 3, 4, 7)
game.move_from_coordinates(game.player2, 6, 6, 5, 6)


def test_blocked_double_pawn():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 4, 5)
game.move_from_coordinates(game.player1, 3, 4, 4, 4)
Expand All @@ -120,7 +116,7 @@ def test_blocked_double_pawn():


def test_king_taking_queen():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 0, 5, 0)
game.move_from_coordinates(game.player1, 0, 3, 4, 7)
Expand All @@ -136,7 +132,7 @@ def test_king_taking_queen():


def specific_test():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 5, 5)
game.move_from_coordinates(game.player1, 0, 3, 4, 7)
Expand All @@ -160,7 +156,7 @@ def specific_test():


def possible_moves():
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 7, 1, 5, 2)
game.move_from_coordinates(game.player1, 3, 4, 4, 4)
Expand Down Expand Up @@ -188,7 +184,7 @@ def possible_moves():

def test_player():
player = ai_player.EasyAIPlayer(False)
game = engine.Game()
game = engine.ChessGame()
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 4, 4, 4)
score = player._score_board(game.board)
Expand Down
18 changes: 9 additions & 9 deletions tests/unit_test/engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_blocked_moves():
"""
Test that a blocked move cannot happen.
"""
game = engine.Game(automatic_draw=False)
game = engine.ChessGame(automatic_draw=False)
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
_, winner = game.move_from_coordinates(game.player2, 7, 0, 5, 0)
assert winner == 0
Expand All @@ -19,7 +19,7 @@ def test_promotion_to_rook():
"""
Test that the promotion works well
"""
game = engine.Game(automatic_draw=False)
game = engine.ChessGame(automatic_draw=False)
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 4, 5)
game.move_from_coordinates(game.player1, 3, 4, 4, 5)
Expand All @@ -40,7 +40,7 @@ def test_default_promotion():
"""
Test that the promotion works well
"""
game = engine.Game(automatic_draw=False)
game = engine.ChessGame(automatic_draw=False)
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 4, 5)
game.move_from_coordinates(game.player1, 3, 4, 4, 5)
Expand All @@ -57,7 +57,7 @@ def test_default_promotion():

def test_working_castling():
"""Tests that small and big castling work."""
game = engine.Game(automatic_draw=False)
game = engine.ChessGame(automatic_draw=False)
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 4, 4, 4)
game.move_from_coordinates(game.player1, 0, 5, 3, 2)
Expand All @@ -83,7 +83,7 @@ def test_working_castling():

def test_failing_castling():
"""Tests conditions where castling cannot be done."""
game = engine.Game(automatic_draw=False)
game = engine.ChessGame(automatic_draw=False)
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 4, 4, 4)
game.move_from_coordinates(game.player1, 0, 5, 3, 2)
Expand All @@ -108,7 +108,7 @@ def test_failing_castling():

def test_en_passant():
"""Tests that prise en passant can be done."""
game = engine.Game(automatic_draw=False)
game = engine.ChessGame(automatic_draw=False)
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 0, 5, 0)
game.move_from_coordinates(game.player1, 3, 4, 4, 4)
Expand All @@ -121,7 +121,7 @@ def test_en_passant():

def test_blocked_by_mat():
"""Tests that if the king is checked cannot move unless it unchecks the king."""
game = engine.Game(automatic_draw=False)
game = engine.ChessGame(automatic_draw=False)
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 4, 5)
game.move_from_coordinates(game.player1, 0, 3, 4, 7)
Expand All @@ -131,7 +131,7 @@ def test_blocked_by_mat():

def test_end_game():
"""Tests what happens when check & mat happens."""
game = engine.Game(automatic_draw=False)
game = engine.ChessGame(automatic_draw=False)
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 4, 5)
game.move_from_coordinates(game.player1, 0, 3, 4, 7)
Expand All @@ -144,7 +144,7 @@ def test_end_game():

def test_pgn():
"""Tests the pgn history of the game."""
game = engine.Game(automatic_draw=False, save_pgn=True)
game = engine.ChessGame(automatic_draw=False, save_pgn=True)
game.move_from_coordinates(game.player1, 1, 4, 3, 4)
game.move_from_coordinates(game.player2, 6, 5, 4, 5)
game.move_from_coordinates(game.player1, 0, 3, 4, 7)
Expand Down

0 comments on commit cff7c53

Please sign in to comment.