def test_board_creation(self): new_board = Board('x', 'o') expected_string = ('| | | |\n' '|--+--+--|\n' '| | | |\n' '|--+--+--|\n' '| | | |\n' '|--+--+--|\n' '<@x> \'s turn is next') assert new_board.turn == new_board.x_player assert new_board.to_string() == expected_string
def create_new_game(self, channel_id, command_text, o_player): if self.ongoing_games.get(channel_id): return create_response(instruction.get_ongoing_game_exists_text(), public=False) try: x_player = get_user_from_start_command(command_text) except InvalidCommandUseException: return create_response( instruction.get_invalid_command_text(START_COMMAND), public=False) new_board = Board(x_player, o_player) self.ongoing_games[channel_id] = new_board response = '<@' + x_player + '> is X.\n' + new_board.to_string() return create_response(response)
def test_move(self): new_board = Board('x', 'o') result = new_board.move(0, 1, 'x') assert new_board.turn == new_board.o_player assert not result result = new_board.move(0, 2, 'o') assert new_board.turn == new_board.x_player assert not result expected_string = ('| | X | O |\n' '|--+--+--|\n' '| | | |\n' '|--+--+--|\n' '| | | |\n' '|--+--+--|\n' '<@x> \'s turn is next') assert new_board.turn == new_board.x_player assert new_board.to_string() == expected_string