from .samples import my_func, MyClass
from ...utils.functions import find_class
from django.test import SimpleTestCase


class FunctionsTest(SimpleTestCase):

    def test_find_class(self):
        MainType = MyClass
        main_type = MainType(11)
        SubType = MyClass.MySubClass
        sub_type = SubType(13)

        def local_func(a: int, b: int):
            return a + b

        # fonction native : None
        self.assertIsNone(find_class(str.join))

        # fonctions : None
        self.assertIsNone(find_class(local_func))
        self.assertIsNone(find_class(my_func))

        # méthodes
        self.assertEqual(find_class(MainType.class_met), MainType)
        self.assertEqual(find_class(MainType.static_met), MainType)
        self.assertEqual(find_class(main_type.std_met), MainType)
        self.assertEqual(find_class(SubType.sub_class_met), SubType)
        self.assertEqual(find_class(SubType.sub_static_met), SubType)
        self.assertEqual(find_class(sub_type.sub_std_met), SubType)
