# 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_10(self) -> bool:
#     if len(self.input_string) == 10:
#         product = 0
# 
#         try:
#             for index, digit in enumerate(self.input_string):
#                 product += int(digit) * (index + 1)
# 
#             return product % 11 == 0
# 
#         except ValueError:
#             pass
# 
#     return False


from unittest import TestCase
from string_utils.errors import InvalidInputError
from string_utils.validation import is_isbn_10



class IsISBN10TestCase(TestCase):
    def test_requires_valid_string(self):
        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: is_isbn_10(None))

        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: is_isbn_10(True))

        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: is_isbn_10(9780312498580))

        # 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/validation.py
# def is_isbn_10(self) -> bool:
#     if len(self.input_string) == 10:
#         product = 0
# 
#         try:
#             for index, digit in enumerate(self.input_string):
#                 product += int(digit) * (index + 1)
# 
#             return product % 11 == 0
# 
#         except ValueError:
#             pass
# 
#     return False


# Path: tests/test_is_isbn_10.py
from unittest import TestCase
from string_utils.errors import InvalidInputError
from string_utils.validation import is_isbn_10




class IsISBN10TestCase(TestCase):
    def test_requires_valid_string(self):
        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: is_isbn_10(None))

        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: is_isbn_10(True))

        # noinspection PyTypeChecker
        self.assertRaises(InvalidInputError, lambda: is_isbn_10(9780312498580))

        # noinspection PyTypeChecker

        self.assertRaises(InvalidInputError, lambda: is_isbn_10([9780312498580]))