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
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
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
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
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