# Path: string_utils/errors.py
# class InvalidInputError(TypeError):
#     """
#     Custom error raised when received object is not a string as expected.
#     """
# 
#     def __init__(self, input_data: Any):
#         """
#         :param input_data: Any received object
#         """
#         type_name = type(input_data).__name__
#         msg = 'Expected "str", received "{}"'.format(type_name)
#         super().__init__(msg)
# 
# Path: string_utils/manipulation.py
# def asciify(input_string: str) -> str:
#     """
#     Force string content to be ascii-only by translating all non-ascii chars into the closest possible representation
#     (eg: ó -> o, Ë -> E, ç -> c...).
# 
#     **Bear in mind**: Some chars may be lost if impossible to translate.
# 
#     *Example:*
# 
#     >>> asciify('èéùúòóäåëýñÅÀÁÇÌÍÑÓË') # returns 'eeuuooaaeynAAACIINOE'
# 
#     :param input_string: String to convert
#     :return: Ascii utf-8 string
#     """
#     if not is_string(input_string):
#         raise InvalidInputError(input_string)
# 
#     # "NFKD" is the algorithm which is able to successfully translate the most of non-ascii chars
#     normalized = unicodedata.normalize('NFKD', input_string)
# 
#     # encode string forcing ascii and ignore any errors (unrepresentable chars will be stripped out)
#     ascii_bytes = normalized.encode('ascii', 'ignore')
# 
#     # turns encoded bytes into an utf-8 string
#     ascii_string = ascii_bytes.decode('utf-8')
# 
#     return ascii_string


from unittest import TestCase
from string_utils.errors import InvalidInputError
from string_utils.manipulation import asciify



class AsciifyTestCase(TestCase):
    def test_raise_exception_if_not_string(self):
        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: asciify(None))

        # noinspection PyTypeChecker

# Path: string_utils/errors.py
# class InvalidInputError(TypeError):
#     """
#     Custom error raised when received object is not a string as expected.
#     """
# 
#     def __init__(self, input_data: Any):
#         """
#         :param input_data: Any received object
#         """
#         type_name = type(input_data).__name__
#         msg = 'Expected "str", received "{}"'.format(type_name)
#         super().__init__(msg)
# 
# Path: string_utils/manipulation.py
# def asciify(input_string: str) -> str:
#     """
#     Force string content to be ascii-only by translating all non-ascii chars into the closest possible representation
#     (eg: ó -> o, Ë -> E, ç -> c...).
# 
#     **Bear in mind**: Some chars may be lost if impossible to translate.
# 
#     *Example:*
# 
#     >>> asciify('èéùúòóäåëýñÅÀÁÇÌÍÑÓË') # returns 'eeuuooaaeynAAACIINOE'
# 
#     :param input_string: String to convert
#     :return: Ascii utf-8 string
#     """
#     if not is_string(input_string):
#         raise InvalidInputError(input_string)
# 
#     # "NFKD" is the algorithm which is able to successfully translate the most of non-ascii chars
#     normalized = unicodedata.normalize('NFKD', input_string)
# 
#     # encode string forcing ascii and ignore any errors (unrepresentable chars will be stripped out)
#     ascii_bytes = normalized.encode('ascii', 'ignore')
# 
#     # turns encoded bytes into an utf-8 string
#     ascii_string = ascii_bytes.decode('utf-8')
# 
#     return ascii_string


# Path: tests/test_asciify.py
from unittest import TestCase
from string_utils.errors import InvalidInputError
from string_utils.manipulation import asciify




class AsciifyTestCase(TestCase):
    def test_raise_exception_if_not_string(self):
        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: asciify(None))

        # noinspection PyTypeChecker

        self.assertRaises(InvalidInputError, lambda: asciify(1))