From 46f17be1a84d741985d5cbfcb63f69ce33c113de Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:12:03 +0200 Subject: [PATCH] Working tests --- .../extensions/tests/test_integration_tests_api.py | 5 +++-- .../tests/test_integration_tests_python.py | 4 ++++ .../tests/utils/integration_tests_api_generator.py | 2 +- .../tests/utils/integration_tests_testers.py | 13 +++++++------ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/openbb_platform/extensions/tests/test_integration_tests_api.py b/openbb_platform/extensions/tests/test_integration_tests_api.py index 5904328a821..e82ba079339 100644 --- a/openbb_platform/extensions/tests/test_integration_tests_api.py +++ b/openbb_platform/extensions/tests/test_integration_tests_api.py @@ -17,13 +17,14 @@ def run_test(test_type: str, check_function) -> None: assert not missing_items, "\n".join(missing_items) -@pytest.mark.skip(reason="Needs uvicorn to be launched but shouldn't be the case.") +# TODO: Check if this can work without being an integration test +@pytest.mark.integration def test_api_interface_integration_test_providers() -> None: """Test if there are any missing providers for integration tests.""" run_test("api", check_missing_integration_test_providers) -@pytest.mark.skip(reason="Needs uvicorn to be launched but shouldn't be the case.") +@pytest.mark.integration def test_api_interface_integration_test_params() -> None: """Test if there are any missing params for integration tests.""" run_test("api", check_missing_integration_test_params) diff --git a/openbb_platform/extensions/tests/test_integration_tests_python.py b/openbb_platform/extensions/tests/test_integration_tests_python.py index 0575ebdc64e..1303b8ed62b 100644 --- a/openbb_platform/extensions/tests/test_integration_tests_python.py +++ b/openbb_platform/extensions/tests/test_integration_tests_python.py @@ -1,4 +1,5 @@ """Test the integration tests.""" +import pytest from extensions.tests.utils.integration_tests_testers import ( check_missing_integration_test_params, check_missing_integration_test_providers, @@ -16,11 +17,14 @@ def run_test(test_type: str, check_function) -> None: assert not missing_items, "\n".join(missing_items) +# TODO: Check if this can work without being an integration test +@pytest.mark.integration def test_python_interface_integration_test_providers() -> None: """Test if there are any missing providers for integration tests.""" run_test("python", check_missing_integration_test_providers) +@pytest.mark.integration def test_python_interface_integration_test_params() -> None: """Test if there are any missing params for integration tests.""" run_test("python", check_missing_integration_test_params) diff --git a/openbb_platform/extensions/tests/utils/integration_tests_api_generator.py b/openbb_platform/extensions/tests/utils/integration_tests_api_generator.py index a69cd915f81..d64cf2ab7de 100644 --- a/openbb_platform/extensions/tests/utils/integration_tests_api_generator.py +++ b/openbb_platform/extensions/tests/utils/integration_tests_api_generator.py @@ -132,7 +132,7 @@ def write_integration_tests( if __name__ == "__main__": - r = requests.get("http://0.0.0.0:8000/openapi.json", timeout=5).json() + r = requests.get("http://0.0.0.0:8000/openapi.json", timeout=10).json() if not r: raise Exception("Could not get openapi.json") diff --git a/openbb_platform/extensions/tests/utils/integration_tests_testers.py b/openbb_platform/extensions/tests/utils/integration_tests_testers.py index 3ec0e0de4a2..3de971d777a 100644 --- a/openbb_platform/extensions/tests/utils/integration_tests_testers.py +++ b/openbb_platform/extensions/tests/utils/integration_tests_testers.py @@ -111,12 +111,13 @@ def check_missing_params( for test_params in function_params: if isinstance(command_params, list): for expected_param in command_params[0]: - if expected_param not in test_params.keys(): - # if return is the expected param, we can ignore - if expected_param != "return": - missing_params.append( - f"Missing param {expected_param} in function {function}" - ) + if ( + expected_param not in test_params.keys() + and expected_param != "return" + ): + missing_params.append( + f"Missing param {expected_param} in function {function}" + ) return missing_params