# Path: rebasehelper/helpers/input_helper.py
# class InputHelper:
# 
#     """Class for command line interaction with the user."""
# 
#     @staticmethod
#     def strtobool(message):
#         """Converts a user message to a corresponding truth value.
# 
#         This method is a replacement for deprecated strtobool from distutils,
#         its behaviour remains the same.
# 
#         Args:
#             message (str): Message to evaluate.
# 
#         Returns:
#             bool: True on 'y', 'yes', 't', 'true', 'on' and '1'.
#                   False on 'n', 'no', 'f', 'false', 'off' and '0'.
# 
#         Raises:
#             ValueError: On any other value.
#         """
#         message = message.lower()
#         if message in ('y', 'yes', 't', 'true', 'on', '1'):
#             return True
#         elif message in ('n', 'no', 'f', 'false', 'off', '0'):
#             return False
#         raise ValueError('No conversion to truth value for "{}"'.format(message))
# 
#     @classmethod
#     def get_message(cls, message, default_yes=True, any_input=False):
#         """Prompts a user with yes/no message and gets the response.
# 
#         Args:
#             message (str): Prompt string.
#             default_yes (bool): If the default value should be YES.
#             any_input (bool): Whether to return default value regardless of input.
# 
#         Returns:
#             bool: True or False, based on user's input.
# 
#         """
#         if default_yes:
#             choice = '[Y/n]'
#         else:
#             choice = '[y/N]'
# 
#         if any_input:
#             msg = '{0} '.format(message)
#         else:
#             msg = '{0} {1}? '.format(message, choice)
# 
#         while True:
#             user_input = input(msg).lower()
# 
#             if not user_input or any_input:
#                 return True if default_yes else False
# 
#             try:
#                 user_input = cls.strtobool(user_input)
#             except ValueError:
#                 logger.error('You have to type y(es) or n(o).')
#                 continue
# 
#             if any_input:
#                 return True
#             else:
#                 return bool(user_input)


import io
import pytest  # type: ignore
from rebasehelper.helpers.input_helper import InputHelper
#          Tomáš Hozza <thozza@redhat.com>
#          Nikola Forró <nforro@redhat.com>
#          František Nečas <fifinecas@seznam.cz>





class TestInputHelper:

    @pytest.mark.parametrize('suffix, answer, kwargs, expected_input', [
        (' [Y/n]? ', 'yes', None, True),
        (' [Y/n]? ', 'no', None, False),
        (' [y/N]? ', 'yes', dict(default_yes=False), True),
        (' [Y/n]? ', '\n', None, True),
        (' [y/N]? ', '\n', dict(default_yes=False), False),
        (' ', 'random input\ndsfdf', dict(any_input=True), True),
        (' ', 'random input\n', dict(default_yes=False, any_input=True), False),
    ], ids=[
        'yes',
        'no',
        'yes-default_no',
        'no_input-default_yes',
        'no_input-default_no',
        'any_input-default_yes',
        'any_input-default_no',
    ])
    def test_get_message(self, monkeypatch, capsys, suffix, answer, kwargs, expected_input):
        question = 'bla bla'
        monkeypatch.setattr('sys.stdin', io.StringIO(answer))

# Path: rebasehelper/helpers/input_helper.py
# class InputHelper:
# 
#     """Class for command line interaction with the user."""
# 
#     @staticmethod
#     def strtobool(message):
#         """Converts a user message to a corresponding truth value.
# 
#         This method is a replacement for deprecated strtobool from distutils,
#         its behaviour remains the same.
# 
#         Args:
#             message (str): Message to evaluate.
# 
#         Returns:
#             bool: True on 'y', 'yes', 't', 'true', 'on' and '1'.
#                   False on 'n', 'no', 'f', 'false', 'off' and '0'.
# 
#         Raises:
#             ValueError: On any other value.
#         """
#         message = message.lower()
#         if message in ('y', 'yes', 't', 'true', 'on', '1'):
#             return True
#         elif message in ('n', 'no', 'f', 'false', 'off', '0'):
#             return False
#         raise ValueError('No conversion to truth value for "{}"'.format(message))
# 
#     @classmethod
#     def get_message(cls, message, default_yes=True, any_input=False):
#         """Prompts a user with yes/no message and gets the response.
# 
#         Args:
#             message (str): Prompt string.
#             default_yes (bool): If the default value should be YES.
#             any_input (bool): Whether to return default value regardless of input.
# 
#         Returns:
#             bool: True or False, based on user's input.
# 
#         """
#         if default_yes:
#             choice = '[Y/n]'
#         else:
#             choice = '[y/N]'
# 
#         if any_input:
#             msg = '{0} '.format(message)
#         else:
#             msg = '{0} {1}? '.format(message, choice)
# 
#         while True:
#             user_input = input(msg).lower()
# 
#             if not user_input or any_input:
#                 return True if default_yes else False
# 
#             try:
#                 user_input = cls.strtobool(user_input)
#             except ValueError:
#                 logger.error('You have to type y(es) or n(o).')
#                 continue
# 
#             if any_input:
#                 return True
#             else:
#                 return bool(user_input)


# Path: rebasehelper/tests/helpers/test_input_helper.py
import io
import pytest  # type: ignore
from rebasehelper.helpers.input_helper import InputHelper

#          Tomáš Hozza <thozza@redhat.com>
#          Nikola Forró <nforro@redhat.com>
#          František Nečas <fifinecas@seznam.cz>





class TestInputHelper:

    @pytest.mark.parametrize('suffix, answer, kwargs, expected_input', [
        (' [Y/n]? ', 'yes', None, True),
        (' [Y/n]? ', 'no', None, False),
        (' [y/N]? ', 'yes', dict(default_yes=False), True),
        (' [Y/n]? ', '\n', None, True),
        (' [y/N]? ', '\n', dict(default_yes=False), False),
        (' ', 'random input\ndsfdf', dict(any_input=True), True),
        (' ', 'random input\n', dict(default_yes=False, any_input=True), False),
    ], ids=[
        'yes',
        'no',
        'yes-default_no',
        'no_input-default_yes',
        'no_input-default_no',
        'any_input-default_yes',
        'any_input-default_no',
    ])
    def test_get_message(self, monkeypatch, capsys, suffix, answer, kwargs, expected_input):
        question = 'bla bla'
        monkeypatch.setattr('sys.stdin', io.StringIO(answer))

        inp = InputHelper.get_message(question, **(kwargs or {}))