Example #1
0
    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'
Example #2
0
    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
Example #3
0
    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
Example #4
0
    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
Example #5
0
    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
Example #6
0
    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
Example #7
0
    def test_get_position(self):
        board = Board()
        player = ComputerPlayer(board)
        board.set_position(4, player)

        assert board.get_position(4) == player
Example #8
0
    def test_set_position(self):
        board = Board()
        computer_player = ComputerPlayer(board)

        assert board.set_position(4, computer_player) == computer_player
Example #9
0
 def test_get_other_player_is_none(self):
     board = Board()
     player = ComputerPlayer(board)
     assert player.get_other_player() is None
Example #10
0
    def test_get_symbol(self):
        board = Board()
        computer_player = ComputerPlayer(board)
        computer_player.symbol = "X"

        assert computer_player.get_symbol() == "X"
Example #11
0
    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"