index creation text fix
This commit is contained in:
parent
adadb6ef0a
commit
ad890ef2bc
3 changed files with 20 additions and 5 deletions
|
|
@ -10,10 +10,10 @@ from dotenv import load_dotenv
|
||||||
# Load environment variables
|
# Load environment variables
|
||||||
load_dotenv()
|
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
|
# This ensures anonymous JWT tokens are created automatically
|
||||||
os.environ.pop('GOOGLE_OAUTH_CLIENT_ID', None)
|
os.environ['GOOGLE_OAUTH_CLIENT_ID'] = ''
|
||||||
os.environ.pop('GOOGLE_OAUTH_CLIENT_SECRET', None)
|
os.environ['GOOGLE_OAUTH_CLIENT_SECRET'] = ''
|
||||||
|
|
||||||
from src.config.settings import clients
|
from src.config.settings import clients
|
||||||
from src.session_manager import SessionManager
|
from src.session_manager import SessionManager
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ async def test_upload_and_search_endpoint(tmp_path: Path, disable_langflow_inges
|
||||||
"src.api.router",
|
"src.api.router",
|
||||||
"src.api.connector_router",
|
"src.api.connector_router",
|
||||||
"src.config.settings",
|
"src.config.settings",
|
||||||
|
"src.auth_middleware",
|
||||||
"src.main",
|
"src.main",
|
||||||
]:
|
]:
|
||||||
sys.modules.pop(mod, None)
|
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()
|
app = await create_app()
|
||||||
# Manually run startup tasks since httpx ASGI transport here doesn't manage lifespan
|
# Manually run startup tasks since httpx ASGI transport here doesn't manage lifespan
|
||||||
await startup_tasks(app.state.services)
|
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
|
# Verify index is truly empty after startup
|
||||||
try:
|
try:
|
||||||
count_response = await clients.opensearch.count(index=INDEX_NAME)
|
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.router",
|
||||||
"src.api.connector_router",
|
"src.api.connector_router",
|
||||||
"src.config.settings",
|
"src.config.settings",
|
||||||
|
"src.auth_middleware",
|
||||||
"src.main",
|
"src.main",
|
||||||
]:
|
]:
|
||||||
sys.modules.pop(mod, None)
|
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()
|
app = await create_app()
|
||||||
await startup_tasks(app.state.services)
|
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
|
# Verify index is truly empty after startup
|
||||||
try:
|
try:
|
||||||
count_response = await clients.opensearch.count(index=INDEX_NAME)
|
count_response = await clients.opensearch.count(index=INDEX_NAME)
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ async def test_startup_ingest_creates_task(disable_langflow_ingest: bool):
|
||||||
"src.api.router",
|
"src.api.router",
|
||||||
"src.api.connector_router",
|
"src.api.connector_router",
|
||||||
"src.config.settings",
|
"src.config.settings",
|
||||||
|
"src.auth_middleware",
|
||||||
"src.main",
|
"src.main",
|
||||||
]:
|
]:
|
||||||
sys.modules.pop(mod, None)
|
sys.modules.pop(mod, None)
|
||||||
|
|
@ -69,6 +70,10 @@ async def test_startup_ingest_creates_task(disable_langflow_ingest: bool):
|
||||||
# Trigger startup tasks explicitly
|
# Trigger startup tasks explicitly
|
||||||
await startup_tasks(app.state.services)
|
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)
|
transport = httpx.ASGITransport(app=app)
|
||||||
try:
|
try:
|
||||||
async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
|
async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue