mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
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:
parent
41eb68663a
commit
4ff712578d
3 changed files with 97 additions and 48 deletions
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue