Underground-Digital/Workflow-Engine
0
1import os2 3from core.helper.module_import_helper import import_module_from_source, load_single_subclass_from_source4from tests.integration_tests.utils.parent_class import ParentClass5 6 7def test_loading_subclass_from_source():8 current_path = os.getcwd()9 module = load_single_subclass_from_source(10 module_name="ChildClass", script_path=os.path.join(current_path, "child_class.py"), parent_type=ParentClass11 )12 assert module13 assert module.__name__ == "ChildClass"14 15 16def test_load_import_module_from_source():17 current_path = os.getcwd()18 module = import_module_from_source(19 module_name="ChildClass", py_file_path=os.path.join(current_path, "child_class.py")20 )21 assert module22 assert module.__name__ == "ChildClass"23 24 25def test_lazy_loading_subclass_from_source():26 current_path = os.getcwd()27 clz = load_single_subclass_from_source(28 module_name="LazyLoadChildClass",29 script_path=os.path.join(current_path, "lazy_load_class.py"),30 parent_type=ParentClass,31 use_lazy_loader=True,32 )33 instance = clz("dify")34 assert instance.get_name() == "dify"35 