refactor: Enhance test utilities for document upload by integrating search space handling

- Updated test fixtures to include search space ID retrieval for improved document upload tests.
- Refactored authentication and document upload functions to accept search space ID as a parameter.
- Removed hardcoded search space ID references to streamline test configurations.
This commit is contained in:
Anish Sarkar 2026-02-25 17:29:09 +05:30
parent 41eb68663a
commit 4ff712578d
3 changed files with 97 additions and 48 deletions

View file

@ -10,10 +10,10 @@ import pytest
from tests.utils.helpers import (
BACKEND_URL,
TEST_SEARCH_SPACE_ID,
auth_headers,
delete_document,
get_auth_token,
get_search_space_id,
)
@ -22,20 +22,24 @@ def backend_url() -> str:
return BACKEND_URL
@pytest.fixture(scope="session")
def search_space_id() -> int:
return TEST_SEARCH_SPACE_ID
@pytest.fixture(scope="session")
async def auth_token(backend_url: str) -> str:
"""Authenticate once per session and return the JWT token."""
"""Authenticate once per session, registering the user if needed."""
async with httpx.AsyncClient(
base_url=backend_url, timeout=30.0
) as client:
return await get_auth_token(client)
@pytest.fixture(scope="session")
async def search_space_id(backend_url: str, auth_token: str) -> int:
"""Discover the first search space belonging to the test user."""
async with httpx.AsyncClient(
base_url=backend_url, timeout=30.0
) as client:
return await get_search_space_id(client, auth_token)
@pytest.fixture(scope="session")
def headers(auth_token: str) -> dict[str, str]:
"""Authorization headers reused across all tests in the session."""