diff --git a/openbb_platform/extensions/etf/integration/test_etf_python.py b/openbb_platform/extensions/etf/integration/test_etf_python.py index 4067fd15931..283a8834a4f 100644 --- a/openbb_platform/extensions/etf/integration/test_etf_python.py +++ b/openbb_platform/extensions/etf/integration/test_etf_python.py @@ -246,45 +246,3 @@ def test_etf_holdings_performance(params, obb): assert result assert isinstance(result, OBBject) assert len(result.results) > 0 - - -@parametrize( - "params", - [({"sort": "desc", "limit": 10})], -) -@pytest.mark.integration -def test_etf_discovery_gainers2(params, obb): - params = {p: v for p, v in params.items() if v} - - result = obb.etf.discovery.gainers(**params) - assert result - assert isinstance(result, OBBject) - assert len(result.results) > 0 - - -@parametrize( - "params", - [({"sort": "desc", "limit": 10})], -) -@pytest.mark.integration -def test_etf_discovery_losers2(params, obb): - params = {p: v for p, v in params.items() if v} - - result = obb.etf.discovery.losers(**params) - assert result - assert isinstance(result, OBBject) - assert len(result.results) > 0 - - -@parametrize( - "params", - [({"sort": "desc", "limit": 10})], -) -@pytest.mark.integration -def test_etf_discovery_active2(params, obb): - params = {p: v for p, v in params.items() if v} - - result = obb.etf.discovery.active(**params) - assert result - assert isinstance(result, OBBject) - assert len(result.results) > 0 diff --git a/openbb_platform/extensions/tests/test_integration_tests_api.py b/openbb_platform/extensions/tests/test_integration_tests_api.py index 4731c80b444..383ceaf9df0 100644 --- a/openbb_platform/extensions/tests/test_integration_tests_api.py +++ b/openbb_platform/extensions/tests/test_integration_tests_api.py @@ -1,17 +1,20 @@ """Test the integration tests.""" +from typing import Literal + from openbb_core.app.charting_service import ChartingService from extensions.tests.utils.integration_tests_testers import ( check_missing_integration_test_params, check_missing_integration_test_providers, check_missing_integration_tests, + check_outdated_integration_tests, check_wrong_integration_test_params, get_integration_tests, get_module_functions, ) -def run_test(test_type: str, check_function) -> None: +def run_test(test_type: Literal["api", "python"], check_function) -> None: """Run tests helper function.""" integration_tests = get_integration_tests(test_type=test_type) functions = get_module_functions(integration_tests) @@ -58,3 +61,9 @@ def test_missing_api_integration_tests() -> None: """Check if there are missing tests.""" missing = check_missing_integration_tests(test_type="api") assert not missing, "\n".join(missing) + + +def test_outdated_api_integration_tests() -> None: + """Check if there are outdated tests.""" + outdated = check_outdated_integration_tests(test_type="api") + assert not outdated, "\n".join(outdated) diff --git a/openbb_platform/extensions/tests/test_integration_tests_python.py b/openbb_platform/extensions/tests/test_integration_tests_python.py index af7baee69e7..08ee8c0449e 100644 --- a/openbb_platform/extensions/tests/test_integration_tests_python.py +++ b/openbb_platform/extensions/tests/test_integration_tests_python.py @@ -1,17 +1,20 @@ """Test the integration tests.""" +from typing import Literal + from openbb_core.app.charting_service import ChartingService from extensions.tests.utils.integration_tests_testers import ( check_missing_integration_test_params, check_missing_integration_test_providers, check_missing_integration_tests, + check_outdated_integration_tests, check_wrong_integration_test_params, get_integration_tests, get_module_functions, ) -def run_test(test_type: str, check_function) -> None: +def run_test(test_type: Literal["api", "python"], check_function) -> None: """Run tests helper function.""" integration_tests = get_integration_tests(test_type=test_type) functions = get_module_functions(integration_tests) @@ -58,3 +61,9 @@ def test_missing_api_integration_tests() -> None: """Check if there are missing tests.""" missing = check_missing_integration_tests(test_type="python") assert not missing, "\n".join(missing) + + +def test_outdated_api_integration_tests() -> None: + """Check if there are outdated tests.""" + outdated = check_outdated_integration_tests(test_type="python") + assert not outdated, "\n".join(outdated) diff --git a/openbb_platform/extensions/tests/utils/integration_tests_testers.py b/openbb_platform/extensions/tests/utils/integration_tests_testers.py index b3fb569d888..125e63e56e6 100644 --- a/openbb_platform/extensions/tests/utils/integration_tests_testers.py +++ b/openbb_platform/extensions/tests/utils/integration_tests_testers.py @@ -295,6 +295,36 @@ def check_missing_integration_tests(test_type: Literal["api", "python"]) -> List return missing_integration_tests +def check_outdated_integration_tests(test_type: Literal["api", "python"]) -> List[str]: + """Check if there are any outdated integration tests.""" + cm = CommandMap(coverage_sep=".") + routes = [route[1:].replace("/", "_") for route in cm.map] + outdated_integration_tests: List[str] = [] + + if test_type == "api": + functions = get_module_functions(get_integration_tests(test_type="api")) + else: + functions = get_module_functions(get_integration_tests(test_type="python")) + + for function, f_callable in functions.items(): + if function.startswith("test_"): + route = function.replace("test_", "", 1) + try: + if f_callable.pytestmark[1].name != "skip": + args = f_callable.pytestmark[1].args[1] + else: + continue + except IndexError: + continue + if route not in routes and len(args) > 0: + # If it doesn't have any args it is because it is not installed. + outdated_integration_tests.append( + f"Outdated {test_type} integration test for route {route}" + ) + + return outdated_integration_tests + + def check_missing_integration_test_providers(functions: Dict[str, Any]) -> List[str]: """Check if there are any missing providers for integration tests.""" return check_integration_tests(functions, check_missing_providers)