Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions airflow-core/tests/unit/api_fastapi/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,15 @@ def dagbag():

parse_and_sync_to_db(os.devnull, include_examples=True)
return DagBag(read_dags_from_db=True)


@pytest.fixture
def get_execution_app():
def _get_execution_app(test_client):
test_app = test_client.app
for route in test_app.router.routes:
if route.path == "/execution":
return route.app
raise RuntimeError("Execution app not found at /execution")

return _get_execution_app
9 changes: 3 additions & 6 deletions airflow-core/tests/unit/api_fastapi/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,11 @@ def test_execution_api_app(mock_create_task_exec_api, mock_init_plugins, mock_in
mock_init_plugins.assert_not_called()


def test_execution_api_app_lifespan(client):
def test_execution_api_app_lifespan(client, get_execution_app):
with client(apps="execution") as test_client:
test_app = test_client.app

# assert the execution app was created and lifespan was called
execution_app = [route.app for route in test_app.router.routes if route.path == "/execution"]
execution_app = get_execution_app(test_client)
assert execution_app, "Execution API app not found in FastAPI app."
assert execution_app[0].state.lifespan_called, "Lifespan not called on Execution API app."
assert execution_app.state.lifespan_called, "Lifespan not called on Execution API app."


@mock.patch("airflow.api_fastapi.app.init_views")
Expand Down