index creation text fix

This commit is contained in:
phact 2025-10-07 01:35:20 -04:00
parent adadb6ef0a
commit ad890ef2bc
3 changed files with 20 additions and 5 deletions

View file

@ -10,10 +10,10 @@ from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Force no-auth mode for testing by removing OAuth credentials
# Force no-auth mode for testing by setting OAuth credentials to empty strings
# This ensures anonymous JWT tokens are created automatically
os.environ.pop('GOOGLE_OAUTH_CLIENT_ID', None)
os.environ.pop('GOOGLE_OAUTH_CLIENT_SECRET', None)
os.environ['GOOGLE_OAUTH_CLIENT_ID'] = ''
os.environ['GOOGLE_OAUTH_CLIENT_SECRET'] = ''
from src.config.settings import clients
from src.session_manager import SessionManager

View file

@ -50,6 +50,7 @@ async def test_upload_and_search_endpoint(tmp_path: Path, disable_langflow_inges
"src.api.router",
"src.api.connector_router",
"src.config.settings",
"src.auth_middleware",
"src.main",
]:
sys.modules.pop(mod, None)
@ -68,7 +69,11 @@ async def test_upload_and_search_endpoint(tmp_path: Path, disable_langflow_inges
app = await create_app()
# Manually run startup tasks since httpx ASGI transport here doesn't manage lifespan
await startup_tasks(app.state.services)
# Ensure index exists for tests (startup_tasks only creates it if DISABLE_INGEST_WITH_LANGFLOW=True)
from src.main import _ensure_opensearch_index
await _ensure_opensearch_index()
# Verify index is truly empty after startup
try:
count_response = await clients.opensearch.count(index=INDEX_NAME)
@ -159,6 +164,7 @@ async def test_router_upload_ingest_traditional(tmp_path: Path, disable_langflow
"src.api.router",
"src.api.connector_router",
"src.config.settings",
"src.auth_middleware",
"src.main",
]:
sys.modules.pop(mod, None)
@ -176,7 +182,11 @@ async def test_router_upload_ingest_traditional(tmp_path: Path, disable_langflow
app = await create_app()
await startup_tasks(app.state.services)
# Ensure index exists for tests (startup_tasks only creates it if DISABLE_INGEST_WITH_LANGFLOW=True)
from src.main import _ensure_opensearch_index
await _ensure_opensearch_index()
# Verify index is truly empty after startup
try:
count_response = await clients.opensearch.count(index=INDEX_NAME)

View file

@ -51,6 +51,7 @@ async def test_startup_ingest_creates_task(disable_langflow_ingest: bool):
"src.api.router",
"src.api.connector_router",
"src.config.settings",
"src.auth_middleware",
"src.main",
]:
sys.modules.pop(mod, None)
@ -69,6 +70,10 @@ async def test_startup_ingest_creates_task(disable_langflow_ingest: bool):
# Trigger startup tasks explicitly
await startup_tasks(app.state.services)
# Ensure index exists for tests (startup_tasks only creates it if DISABLE_INGEST_WITH_LANGFLOW=True)
from src.main import _ensure_opensearch_index
await _ensure_opensearch_index()
transport = httpx.ASGITransport(app=app)
try:
async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client: