Dev-iL commented on code in PR #73414:
URL: https://github.com/apache/airflow/pull/73414#discussion_r4308099081
##########
airflow-core/tests/unit/api_fastapi/execution_api/test_app.py:
##########
@@ -96,6 +97,96 @@ def
test_server_and_in_process_apps_isolate_auth(in_process_first, monkeypatch):
assert authenticated_response.json() == response.json()
[email protected]("failure", [None, "startup", "shutdown", "dispose",
"configure"])
[email protected]("airflow.api_fastapi.execution_api.app.InProcessExecutionAPI",
autospec=True)
+def test_in_process_fixture_owns_engine_lifetime(mock_api, request, failure):
+ previous_engine, previous_factory = settings.async_engine,
settings.AsyncSession
+ api = InProcessExecutionAPI()
+ mock_api.return_value = api
+ original_lifespan = api.app.router.lifespan_context
+ disposed = []
+ original_dispose = AsyncEngine.dispose
+ original_configure = settings._configure_async_session
+
+ @asynccontextmanager
+ async def lifespan(app):
+ async with original_lifespan(app):
+ if failure == "startup":
+ raise RuntimeError("startup failed")
+ yield
+ if failure == "shutdown":
+ raise RuntimeError("shutdown failed")
+
+ api.app.router.lifespan_context = lifespan
+
+ async def dispose(engine, *args, **kwargs):
+ disposed.append((engine, asyncio.get_running_loop()))
+ await original_dispose(engine, *args, **kwargs)
+ if engine is not previous_engine and failure == "dispose":
+ raise RuntimeError("dispose failed")
+
+ def configure():
+ original_configure()
+ if failure == "configure":
+ raise RuntimeError("configure failed")
+
+ async def query(factory):
+ async with factory() as session:
+ return await session.scalar(text("SELECT 1"))
+
+ @api.app.get("/fixture-db-read")
+ async def read():
+ return await query(settings.AsyncSession)
+
+ fixture =
request._fixturemanager.getfixturedefs("in_process_execution_api",
request.node)[-1].func
Review Comment:
Removed both fixture-introspection tests, including
request._fixturemanager/getfixturedefs and fresh_async_engine.__wrapped__. The
fixtures are still consumed through normal pytest injection, and the existing
Dag processor and triggerer integration tests retain coverage of their use.
---
Drafted-by: Codex (GPT-6) (reviewed by @Dev-iL)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]