def test_render_position_returns_symbol_when_position_is_not_empty(self): board = Board() ui = ConsoleUI(board) player = ComputerPlayer(board) player.symbol = 'X' board.set_position(4, player) assert ui.render_position(4) == 'X'
def test_get_other_player_when_position_not_empty(self): board = Board() ui = ConsoleUI(board) computer = ComputerPlayer(board) human = HumanPlayer(board, ui) board.set_position(4, computer) board.set_position(5, human) assert computer.get_other_player() == human
def test_game_is_not_over(self): board = Board() player = ComputerPlayer(board) board.set_position(3, player) board.set_position(4, player) board.set_position(8, player) assert board.game_is_over() is False
def test_is_not_three_in_a_row(self): board = Board() player = ComputerPlayer(board) board.set_position(2, player) board.set_position(4, player) board.set_position(5, player) assert board.three_in_a_row(3, 4, 5) is False
def test_is_full(self): board = Board() player = ComputerPlayer(board) board.set_position(0, player) board.set_position(1, player) board.set_position(2, player) board.set_position(3, player) board.set_position(4, player) board.set_position(5, player) board.set_position(6, player) board.set_position(7, player) board.set_position(8, player) assert board.is_full() is True
def test_position_is_not_empty(self): board = Board() player = ComputerPlayer(board) board.set_position(4, player) assert board.position_is_empty(4) is False
def test_get_position(self): board = Board() player = ComputerPlayer(board) board.set_position(4, player) assert board.get_position(4) == player
def test_set_position(self): board = Board() computer_player = ComputerPlayer(board) assert board.set_position(4, computer_player) == computer_player
def test_get_other_player_is_none(self): board = Board() player = ComputerPlayer(board) assert player.get_other_player() is None
def test_get_symbol(self): board = Board() computer_player = ComputerPlayer(board) computer_player.symbol = "X" assert computer_player.get_symbol() == "X"
def test_choose_symbol_other_player_picks_o(self): board = Board() computer_player = ComputerPlayer(board) computer_player.choose_symbol(other_player_symbol='O') assert computer_player.symbol == "X"