def test_get_game(self, mock_game): test_new_game = Game(3, "playerX", "playerO") test_new_game.board_size = 3 test_new_game.player_x = "playerX" test_new_game.player_o = "playerO" test_new_game.your_move = "X" test_new_game.board_blob = json.dumps( ['', '', 'X', '', '', '', '', '', '']) mock_game.query.filter_by.return_value.first.return_value = test_new_game assert (get_game(0) == test_new_game)
def test_if_proper_move_by_player(self, mock_game): test_new_game = Game(3, "playerX", "playerO") test_new_game.board_size = 3 test_new_game.player_x = "playerX" test_new_game.player_o = "playerO" test_new_game.your_move = "X" test_new_game.board_blob = json.dumps( ['', '', 'X', '', 'O', '', 'X', '', '']) assert (test_new_game.save_player_move(1, 'X') is True) assert (test_new_game.save_player_move(2, 'O') is False)
def test_case_if_3_in_row(self, mock_game): test_game = Game(3, "playerX", "playerO") test_game.game_id = 1 test_game.board_size = 3 test_game.player_x = "playerX" test_game.player_o = "playerO" test_game.your_move = "X" test_game.board_blob = json.dumps( ['X', 'X', 'X', 'X', '', 'O', 'X', 'O', '']) assert (test_game.is_row_won(0, 'X') is True) assert (test_game.is_row_won(1, 'O') is False) assert (test_game.is_row_won(2, 'O') is False) assert (test_game.is_row_won(2, 'X') is False)