- Add TEST_HOST config (default: 192.168.86.149) in conftest.py - Update all test fixtures to use configurable host instead of docker hostnames (neo4j, qdrant, wiki, etc.) - Fix test_integration.py WikiJS client to use username/password auth - Fix ollama_client fixture to use ollama_embedding_model setting This allows tests to run against real services from outside Docker. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
121 lines
2.8 KiB
Python
121 lines
2.8 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",
|
|
"username": settings.wikijs_username,
|
|
"password": settings.wikijs_password
|
|
}
|
|
|
|
|
|
@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)]
|
|
]
|