# 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/validation.py
# def is_isbn(input_string: str, normalize: bool = True) -> bool:
#     """
#     Checks if the given string represents a valid ISBN (International Standard Book Number).
#     By default hyphens in the string are ignored, so digits can be separated in different ways, by calling this
#     function with `normalize=False` only digit-only strings will pass the validation.
# 
#     *Examples:*
# 
#     >>> is_isbn('9780312498580') # returns true
#     >>> is_isbn('1506715214') # returns true
# 
#     :param input_string: String to check.
#     :param normalize: True to ignore hyphens ("-") in the string (default), false otherwise.
#     :return: True if valid ISBN (10 or 13), false otherwise.
#     """
#     checker = __ISBNChecker(input_string, normalize)
#     return checker.is_isbn_13() or checker.is_isbn_10()


from unittest import TestCase
from string_utils.errors import InvalidInputError
from string_utils.validation import is_isbn
        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: is_isbn([9780312498580]))

    def test_returns_true_for_valid_isbn_10(self):
        # isbn numbers have been taken from actual books on amazon
        self.assertTrue(is_isbn('1506715214'))
        self.assertTrue(is_isbn('1506715532'))
        self.assertTrue(is_isbn('0451494504'))
        self.assertTrue(is_isbn('0718079183'))
        self.assertTrue(is_isbn('8830102180'))
        
    def test_returns_true_for_valid_isbn_13(self):
        # isbn numbers have been taken from actual books on amazon
        self.assertTrue(is_isbn('9780312498580'))
        self.assertTrue(is_isbn('9781941325827'))
        self.assertTrue(is_isbn('9780062853851'))
        self.assertTrue(is_isbn('9781250107817'))
        self.assertTrue(is_isbn('9788891229243'))

    def test_hyphens_are_not_considered_by_default(self):
        # isbn numbers have been taken from actual books on amazon
        self.assertTrue(is_isbn('150-6715214'))
        self.assertTrue(is_isbn('150-671-5532'))
        self.assertTrue(is_isbn('045-14-94-50-4'))
        self.assertTrue(is_isbn('071-8-0-7-9-1-8-3'))
        self.assertTrue(is_isbn('8-8-3-0-1-0-2-1-8-0'))
        self.assertTrue(is_isbn('978-0312498580'))
        self.assertTrue(is_isbn('978-194-132-582-7'))
        self.assertTrue(is_isbn('978-0-0-6-2-8-5-3-8-5-1'))


# 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/validation.py
# def is_isbn(input_string: str, normalize: bool = True) -> bool:
#     """
#     Checks if the given string represents a valid ISBN (International Standard Book Number).
#     By default hyphens in the string are ignored, so digits can be separated in different ways, by calling this
#     function with `normalize=False` only digit-only strings will pass the validation.
# 
#     *Examples:*
# 
#     >>> is_isbn('9780312498580') # returns true
#     >>> is_isbn('1506715214') # returns true
# 
#     :param input_string: String to check.
#     :param normalize: True to ignore hyphens ("-") in the string (default), false otherwise.
#     :return: True if valid ISBN (10 or 13), false otherwise.
#     """
#     checker = __ISBNChecker(input_string, normalize)
#     return checker.is_isbn_13() or checker.is_isbn_10()


# Path: tests/test_is_isbn.py
from unittest import TestCase
from string_utils.errors import InvalidInputError
from string_utils.validation import is_isbn

        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: is_isbn([9780312498580]))

    def test_returns_true_for_valid_isbn_10(self):
        # isbn numbers have been taken from actual books on amazon
        self.assertTrue(is_isbn('1506715214'))
        self.assertTrue(is_isbn('1506715532'))
        self.assertTrue(is_isbn('0451494504'))
        self.assertTrue(is_isbn('0718079183'))
        self.assertTrue(is_isbn('8830102180'))
        
    def test_returns_true_for_valid_isbn_13(self):
        # isbn numbers have been taken from actual books on amazon
        self.assertTrue(is_isbn('9780312498580'))
        self.assertTrue(is_isbn('9781941325827'))
        self.assertTrue(is_isbn('9780062853851'))
        self.assertTrue(is_isbn('9781250107817'))
        self.assertTrue(is_isbn('9788891229243'))

    def test_hyphens_are_not_considered_by_default(self):
        # isbn numbers have been taken from actual books on amazon
        self.assertTrue(is_isbn('150-6715214'))
        self.assertTrue(is_isbn('150-671-5532'))
        self.assertTrue(is_isbn('045-14-94-50-4'))
        self.assertTrue(is_isbn('071-8-0-7-9-1-8-3'))
        self.assertTrue(is_isbn('8-8-3-0-1-0-2-1-8-0'))
        self.assertTrue(is_isbn('978-0312498580'))
        self.assertTrue(is_isbn('978-194-132-582-7'))
        self.assertTrue(is_isbn('978-0-0-6-2-8-5-3-8-5-1'))


    def test_isbn_not_recognized_if_normalization_is_disabled(self):