mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
"""Root conftest — shared fixtures available to all test modules."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from dotenv import load_dotenv
|
|
|
|
from app.db import DocumentType
|
|
from app.indexing_pipeline.connector_document import ConnectorDocument
|
|
|
|
load_dotenv(Path(__file__).resolve().parent.parent / ".env")
|
|
|
|
# Shared DB URL referenced by both e2e and integration helper functions.
|
|
DATABASE_URL = os.environ.get(
|
|
"TEST_DATABASE_URL",
|
|
os.environ.get("DATABASE_URL", ""),
|
|
).replace("postgresql+asyncpg://", "postgresql://")
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Unit test fixtures
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_user_id() -> str:
|
|
return "00000000-0000-0000-0000-000000000001"
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_search_space_id() -> int:
|
|
return 1
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_connector_id() -> int:
|
|
return 42
|
|
|
|
|
|
@pytest.fixture
|
|
def make_connector_document():
|
|
"""
|
|
Generic factory for unit tests. Overridden in tests/integration/conftest.py
|
|
with real DB-backed IDs for integration tests.
|
|
"""
|
|
|
|
def _make(**overrides):
|
|
defaults = {
|
|
"title": "Test Document",
|
|
"source_markdown": "## Heading\n\nSome content.",
|
|
"unique_id": "test-id-001",
|
|
"document_type": DocumentType.CLICKUP_CONNECTOR,
|
|
"search_space_id": 1,
|
|
"connector_id": 1,
|
|
"created_by_id": "00000000-0000-0000-0000-000000000001",
|
|
}
|
|
defaults.update(overrides)
|
|
return ConnectorDocument(**defaults)
|
|
|
|
return _make
|