Esempio n. 1
0
def test_cannot_place_over_another_tile():
    ttt = TicTacToe()
    ttt.board = {
        1: {
            1: 'X',
            2: 'O',
            3: ' '
        },
        2: {
            1: ' ',
            2: ' ',
            3: ' '
        },
        3: {
            1: ' ',
            2: ' ',
            3: ' '
        }
    }
    ttt.GAME_STATE = ttt.STATES.CROSS_TURN
    assert ttt.place_marker("X", 1, 1) == False
Esempio n. 2
0
def test_place_marker():
    ttt = TicTacToe()
    ttt.board = {
        1: {
            1: 'X',
            2: 'O',
            3: ' '
        },
        2: {
            1: ' ',
            2: ' ',
            3: ' '
        },
        3: {
            1: ' ',
            2: ' ',
            3: ' '
        }
    }
    ttt.GAME_STATE = ttt.STATES.CROSS_TURN
    assert ttt.place_marker("X", 1, 3)
    newBoard = {
        1: {
            1: 'X',
            2: 'O',
            3: 'X'
        },
        2: {
            1: ' ',
            2: ' ',
            3: ' '
        },
        3: {
            1: ' ',
            2: ' ',
            3: ' '
        }
    }
    assert ttt.GAME_STATE == ttt.STATES.NAUGHT_TURN
    assert ttt.board == newBoard
Esempio n. 3
0
def test_valid_input_marker():
    ttt = TicTacToe()
    ttt.board = {
        1: {
            1: 'X',
            2: 'O',
            3: ' '
        },
        2: {
            1: ' ',
            2: ' ',
            3: ' '
        },
        3: {
            1: ' ',
            2: ' ',
            3: ' '
        }
    }
    ttt.GAME_STATE = ttt.STATES.CROSS_TURN
    assert ttt.place_marker("Y", 2, 2) == False
    assert ttt.GAME_STATE == ttt.STATES.CROSS_TURN
Esempio n. 4
0
def test_out_of_bounds():
    ttt = TicTacToe()
    ttt.board = {
        1: {
            1: 'X',
            2: 'O',
            3: ' '
        },
        2: {
            1: ' ',
            2: ' ',
            3: ' '
        },
        3: {
            1: ' ',
            2: ' ',
            3: ' '
        }
    }
    ttt.GAME_STATE = ttt.STATES.CROSS_TURN
    assert ttt.place_marker("X", 4, 4) == False
    assert ttt.GAME_STATE == ttt.STATES.CROSS_TURN
Esempio n. 5
0
def test_my_turn():
    ttt = TicTacToe()
    ttt.board = {
        1: {
            1: 'X',
            2: 'O',
            3: ' '
        },
        2: {
            1: ' ',
            2: ' ',
            3: ' '
        },
        3: {
            1: ' ',
            2: ' ',
            3: ' '
        }
    }
    ttt.GAME_STATE = ttt.STATES.CROSS_TURN
    assert ttt.place_marker("O", 1, 1) == False
    assert ttt.GAME_STATE == ttt.STATES.CROSS_TURN