Skip to content

Commit 86796b6

Browse files
committed
fixed integration tests
1 parent bf17f06 commit 86796b6

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

tests/integration/core/test_startup_ingest.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ def count_files_in_documents() -> int:
3737

3838
@pytest.mark.parametrize("disable_langflow_ingest", [True, False])
3939
@pytest.mark.asyncio
40-
async def test_startup_ingest_creates_task(disable_langflow_ingest: bool):
40+
async def test_startup_ingest_creates_task(disable_langflow_ingest: bool, monkeypatch):
4141
# Ensure startup ingest runs and choose pipeline per param
42-
os.environ["DISABLE_STARTUP_INGEST"] = "false"
43-
os.environ["DISABLE_INGEST_WITH_LANGFLOW"] = (
44-
"true" if disable_langflow_ingest else "false"
42+
monkeypatch.setenv("DISABLE_STARTUP_INGEST", "false")
43+
monkeypatch.setenv(
44+
"DISABLE_INGEST_WITH_LANGFLOW", "true" if disable_langflow_ingest else "false"
4545
)
4646
# Force no-auth mode for simpler endpoint access
47-
os.environ["GOOGLE_OAUTH_CLIENT_ID"] = ""
48-
os.environ["GOOGLE_OAUTH_CLIENT_SECRET"] = ""
47+
monkeypatch.setenv("GOOGLE_OAUTH_CLIENT_ID", "")
48+
monkeypatch.setenv("GOOGLE_OAUTH_CLIENT_SECRET", "")
4949

5050
# Reload settings to pick up env for this test run
5151
import sys
@@ -70,8 +70,9 @@ async def test_startup_ingest_creates_task(disable_langflow_ingest: bool):
7070
pass
7171

7272
app = await create_app()
73-
# Trigger startup tasks explicitly
74-
await startup_tasks(app.state.services)
73+
lifespan_ctx = app.router.lifespan_context(app)
74+
await lifespan_ctx.__aenter__()
75+
app.state.lifespan_ctx = lifespan_ctx
7576

7677
# Ensure index exists for tests (startup_tasks only creates it if DISABLE_INGEST_WITH_LANGFLOW=True)
7778
from main import _ensure_opensearch_index
@@ -113,6 +114,7 @@ async def _wait_for_task(timeout_s: float = 60.0):
113114
assert "task_id" in newest
114115
assert newest.get("total_files") == expected_files
115116
finally:
117+
await lifespan_ctx.__aexit__(None, None, None)
116118
# Explicitly close global clients to avoid aiohttp warnings
117119
from config.settings import clients
118120
try:

0 commit comments

Comments
 (0)