Working tests

This commit is contained in:
Igor Radovanovic
2023-10-04 23:12:03 +02:00
parent 66dbb9a1df
commit 46f17be1a8
4 changed files with 15 additions and 9 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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")

View File

@@ -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