diff --git a/openbb_platform/extensions/tests/test_integration_tests.py b/openbb_platform/extensions/tests/test_integration_tests.py index 6509094eff7..e59987d111f 100644 --- a/openbb_platform/extensions/tests/test_integration_tests.py +++ b/openbb_platform/extensions/tests/test_integration_tests.py @@ -2,24 +2,35 @@ from extensions.tests.utils.integration_tests_testers import ( check_missing_integration_test_params, check_missing_integration_test_providers, + get_integration_tests, get_module_functions, - get_python_integration_tests, ) +def run_test(test_type: str, check_function) -> None: + """Run tests helper function.""" + integration_tests = get_integration_tests(test_type=test_type) + functions = get_module_functions(integration_tests) + missing_items = check_function(functions) + + assert not missing_items, "\n".join(missing_items) + + def test_python_interface_integration_tests() -> None: """Test if there are any missing providers for integration tests.""" - integration_tests = get_python_integration_tests() - functions = get_module_functions(integration_tests) - missing_providers = check_missing_integration_test_providers(functions) - - assert not missing_providers, "\n".join(missing_providers) + run_test("unit", check_missing_integration_test_providers) def test_python_interface_integration_test_params() -> None: """Test if there are any missing params for integration tests.""" - integration_tests = get_python_integration_tests() - functions = get_module_functions(integration_tests) - missing_params = check_missing_integration_test_params(functions) + run_test("unit", check_missing_integration_test_params) - assert not missing_params, "\n".join(missing_params) + +def test_api_interface_integration_tests() -> None: + """Test if there are any missing providers for integration tests.""" + run_test("integration", check_missing_integration_test_providers) + + +def test_api_interface_integration_test_params() -> None: + """Test if there are any missing params for integration tests.""" + run_test("integration", check_missing_integration_test_params) diff --git a/openbb_platform/extensions/tests/utils/integration_tests_testers.py b/openbb_platform/extensions/tests/utils/integration_tests_testers.py index ea4f248c9b3..28864f063d5 100644 --- a/openbb_platform/extensions/tests/utils/integration_tests_testers.py +++ b/openbb_platform/extensions/tests/utils/integration_tests_testers.py @@ -2,21 +2,26 @@ import importlib.util import inspect import os -from platform.core.openbb_core.app.provider_interface import ProviderInterface -from platform.core.openbb_core.app.router import CommandMap -from typing import Any, Callable, Dict, List +from typing import Any, Callable, Dict, List, Literal from extensions.tests.utils.integration_tests_generator import find_extensions +from openbb_core.app.provider_interface import ProviderInterface +from openbb_core.app.router import CommandMap -def get_python_integration_tests() -> List[Any]: +def get_integration_tests(test_type: Literal["integration", "unit"]) -> List[Any]: """Get integration tests for the python interface.""" integration_tests: List[Any] = [] + if test_type == "unit": + file_end = "_python.py" + elif test_type == "integration": + file_end = "_api.py" + for extension in find_extensions(): integration_folder = os.path.join(extension, "integration") for file in os.listdir(integration_folder): - if file.endswith("_python.py"): + if file.endswith(file_end): file_path = os.path.join(integration_folder, file) module_name = file[:-3] # Remove .py from file name