From ce77af922af66e7045e0437ea95398796c4c910f Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Sun, 6 Jul 2025 15:40:25 +0200 Subject: [PATCH] Clean up tests for partial dependencies and rename to `test_dependency_partial.py` --- ...cy_types.py => test_dependency_partial.py} | 104 +----------------- 1 file changed, 4 insertions(+), 100 deletions(-) rename tests/{test_dependency_types.py => test_dependency_partial.py} (65%) diff --git a/tests/test_dependency_types.py b/tests/test_dependency_partial.py similarity index 65% rename from tests/test_dependency_types.py rename to tests/test_dependency_partial.py index 6e22dd811..5caffeec1 100644 --- a/tests/test_dependency_types.py +++ b/tests/test_dependency_partial.py @@ -65,82 +65,6 @@ async_callable_gen_dependency = AsyncCallableGenDependency() methods_dependency = MethodsDependency() -@app.get("/function-dependency") -async def get_function_dependency(value: str = Depends(function_dependency)) -> str: - return value - - -@app.get("/async-function-dependency") -async def get_async_function_dependency( - value: str = Depends(async_function_dependency), -) -> str: - return value - - -@app.get("/gen-dependency") -async def get_gen_dependency(value: str = Depends(gen_dependency)) -> str: - return value - - -@app.get("/async-gen-dependency") -async def get_async_gen_dependency(value: str = Depends(async_gen_dependency)) -> str: - return value - - -@app.get("/callable-dependency") -async def get_callable_dependency(value: str = Depends(callable_dependency)) -> str: - return value - - -@app.get("/callable-gen-dependency") -async def get_callable_gen_dependency( - value: str = Depends(callable_gen_dependency), -) -> str: - return value - - -@app.get("/async-callable-dependency") -async def get_async_callable_dependency( - value: str = Depends(async_callable_dependency), -) -> str: - return value - - -@app.get("/async-callable-gen-dependency") -async def get_async_callable_gen_dependency( - value: str = Depends(async_callable_gen_dependency), -) -> str: - return value - - -@app.get("/synchronous-method-dependency") -async def get_synchronous_method_dependency( - value: str = Depends(methods_dependency.synchronous), -) -> str: - return value - - -@app.get("/synchronous-method-gen-dependency") -async def get_synchronous_method_gen_dependency( - value: str = Depends(methods_dependency.synchronous_gen), -) -> str: - return value - - -@app.get("/asynchronous-method-dependency") -async def get_asynchronous_method_dependency( - value: str = Depends(methods_dependency.asynchronous), -) -> str: - return value - - -@app.get("/asynchronous-method-gen-dependency") -async def get_asynchronous_method_gen_dependency( - value: str = Depends(methods_dependency.asynchronous_gen), -) -> str: - return value - - @app.get("/partial-function-dependency") async def get_partial_function_dependency( value: str = Depends(partial(function_dependency, "partial-function-dependency")), @@ -252,34 +176,14 @@ async def get_partial_asynchronous_method_gen_dependency( client = TestClient(app) -@pytest.mark.parametrize( - "route,value", - [ - ("/function-dependency", "function-dependency"), - ("/async-function-dependency", "async-function-dependency"), - ("/gen-dependency", "gen-dependency"), - ("/async-gen-dependency", "async-gen-dependency"), - ("/callable-dependency", "callable-dependency"), - ("/callable-gen-dependency", "callable-gen-dependency"), - ("/async-callable-dependency", "async-callable-dependency"), - ("/async-callable-gen-dependency", "async-callable-gen-dependency"), - ("/synchronous-method-dependency", "synchronous-method-dependency"), - ("/synchronous-method-gen-dependency", "synchronous-method-gen-dependency"), - ("/asynchronous-method-dependency", "asynchronous-method-dependency"), - ("/asynchronous-method-gen-dependency", "asynchronous-method-gen-dependency"), - ], -) -def test_dependency_types(route: str, value: str) -> None: - response = client.get(route, params={"value": value}) - assert response.status_code == 200, response.text - assert response.json() == value - - @pytest.mark.parametrize( "route,value", [ ("/partial-function-dependency", "partial-function-dependency"), - ("/partial-async-function-dependency", "partial-async-function-dependency"), + ( + "/partial-async-function-dependency", + "partial-async-function-dependency", + ), ("/partial-gen-dependency", "partial-gen-dependency"), ("/partial-async-gen-dependency", "partial-async-gen-dependency"), ("/partial-callable-dependency", "partial-callable-dependency"),