| 1 |
import sys |
| 2 |
|
| 3 |
import pytest |
| 4 |
|
| 5 |
from tests.benchmarks.utils import ( |
| 6 |
ROUTE_COUNT, |
| 7 |
ROUTE_PATH_PREFIX, |
| 8 |
create_openapi_app, |
| 9 |
generate_openapi, |
| 10 |
) |
| 11 |
|
| 12 |
if "--codspeed" not in sys.argv: |
| 13 |
pytest.skip( |
| 14 |
"Benchmark tests are skipped by default; run with --codspeed.", |
| 15 |
allow_module_level=True, |
| 16 |
) |
| 17 |
|
| 18 |
|
| 19 |
@pytest.mark.timeout(60) |
| 20 |
def test_openapi_dependency_graph(benchmark) -> None: |
| 21 |
app = create_openapi_app() |
| 22 |
schema = benchmark(generate_openapi, app) |
| 23 |
dynamic_paths = [ |
| 24 |
path for path in schema["paths"] if path.startswith(ROUTE_PATH_PREFIX) |
| 25 |
] |
| 26 |
assert len(dynamic_paths) == ROUTE_COUNT |
| 27 |
assert all( |
| 28 |
any( |
| 29 |
parameter["in"] == "query" and parameter["name"] == "query_value" |
| 30 |
for parameter in schema["paths"][path]["get"]["parameters"] |
| 31 |
) |
| 32 |
for path in dynamic_paths |
| 33 |
) |