Files
library-desk/tests/conftest.py
T
jpmschweitzerandClaude Opus 4.5 1f47b052d8 feat: add unified memory routing to consolidation service
- Add MemoryRouteClassification and MemoryRoutingResult models
- Implement unified classifier (_classify_web_results_unified) that routes
  web results to: wiki, volatile, file (Paperless), prefetch, or skip
- Add routing methods: _route_to_volatile, _route_to_files, _register_prefetch
- Update _process_search to use unified classifier instead of separate analysis
- Add get_volatile_cache_service factory to dependencies
- Wire volatile_service and settings_client into ConsolidationService
- Update ConsolidationResult/Response with new routing counters

Test fixes:
- Fix WikiJSClient fixtures to use api_token instead of username/password
- Fix entity linking test assertions to expect full user-namespaced paths
- Add sample_unified_classification fixture for new classifier format

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 17:19:20 +01:00

120 lines
2.7 KiB
Python

"""Pytest configuration and shared fixtures for Library Desk tests."""
import os
import pytest
import pytest_asyncio
from typing import AsyncGenerator
# Test configuration
pytest_plugins = ("pytest_asyncio",)
# Use real host for tests (services available at this IP)
TEST_HOST = os.environ.get("TEST_HOST", "192.168.86.149")
@pytest.fixture
def test_user() -> str:
"""Default test user."""
return "test_user"
@pytest.fixture
def neo4j_test_uri() -> str:
"""Test Neo4j URI."""
return f"bolt://{TEST_HOST}:7687"
@pytest.fixture
def neo4j_test_auth() -> tuple:
"""Test Neo4j authentication."""
from src.config import get_settings
settings = get_settings()
return ("neo4j", settings.neo4j_password)
@pytest.fixture
def qdrant_test_url() -> str:
"""Test Qdrant URL."""
return f"http://{TEST_HOST}:6333"
@pytest.fixture
def wikijs_test_config() -> dict:
"""Test Wiki.js configuration."""
from src.config import get_settings
settings = get_settings()
return {
"base_url": f"http://{TEST_HOST}:3000",
"api_token": settings.wiki_graphql_api
}
@pytest.fixture
def searxng_test_url() -> str:
"""Test SearXNG URL."""
return f"http://{TEST_HOST}:8080"
@pytest.fixture
def ollama_test_config() -> dict:
"""Test Ollama configuration."""
from src.config import get_settings
settings = get_settings()
return {
"base_url": f"http://{TEST_HOST}:11434",
"model": settings.ollama_embedding_model
}
@pytest.fixture
def redis_test_url() -> str:
"""Test Redis URL."""
return f"redis://{TEST_HOST}:6379/4"
@pytest.fixture
def sample_document() -> dict:
"""Sample document for testing."""
return {
"id": "test_doc_1",
"title": "Test Document",
"content": "This is a test document for unit testing.",
"metadata": {
"source": "test",
"author": "test_user"
}
}
@pytest.fixture
def sample_chunks() -> list:
"""Sample document chunks for testing."""
return [
{
"content": "First chunk of text.",
"metadata": {"chunk_index": 0}
},
{
"content": "Second chunk of text.",
"metadata": {"chunk_index": 1}
},
{
"content": "Third chunk of text.",
"metadata": {"chunk_index": 2}
}
]
@pytest.fixture
def sample_embeddings() -> list:
"""Sample embeddings for testing (768-dimensional for nomic-embed-text)."""
import random
random.seed(42) # Reproducible embeddings
# Generate 3 sample 768-dimensional embeddings
return [
[random.random() for _ in range(768)],
[random.random() for _ in range(768)],
[random.random() for _ in range(768)]
]