Check if outdated (#5898)

This commit is contained in:
Igor Radovanovic
2023-12-18 11:24:02 +01:00
committed by GitHub
parent 238ab39a50
commit ecdb111fd5
4 changed files with 50 additions and 44 deletions

View File

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

View File

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

View File

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

View File

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