test: update fixtures to use real service host
- 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>
This commit is contained in:
+20
-9
@@ -1,5 +1,6 @@
|
|||||||
"""Pytest configuration and shared fixtures for Library Desk tests."""
|
"""Pytest configuration and shared fixtures for Library Desk tests."""
|
||||||
|
|
||||||
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
import pytest_asyncio
|
import pytest_asyncio
|
||||||
from typing import AsyncGenerator
|
from typing import AsyncGenerator
|
||||||
@@ -7,6 +8,9 @@ from typing import AsyncGenerator
|
|||||||
# Test configuration
|
# Test configuration
|
||||||
pytest_plugins = ("pytest_asyncio",)
|
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
|
@pytest.fixture
|
||||||
def test_user() -> str:
|
def test_user() -> str:
|
||||||
@@ -17,49 +21,56 @@ def test_user() -> str:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def neo4j_test_uri() -> str:
|
def neo4j_test_uri() -> str:
|
||||||
"""Test Neo4j URI."""
|
"""Test Neo4j URI."""
|
||||||
return "bolt://neo4j:7687"
|
return f"bolt://{TEST_HOST}:7687"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def neo4j_test_auth() -> tuple:
|
def neo4j_test_auth() -> tuple:
|
||||||
"""Test Neo4j authentication."""
|
"""Test Neo4j authentication."""
|
||||||
return ("neo4j", "test_password")
|
from src.config import get_settings
|
||||||
|
settings = get_settings()
|
||||||
|
return ("neo4j", settings.neo4j_password)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def qdrant_test_url() -> str:
|
def qdrant_test_url() -> str:
|
||||||
"""Test Qdrant URL."""
|
"""Test Qdrant URL."""
|
||||||
return "http://qdrant:6333"
|
return f"http://{TEST_HOST}:6333"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def wikijs_test_config() -> dict:
|
def wikijs_test_config() -> dict:
|
||||||
"""Test Wiki.js configuration."""
|
"""Test Wiki.js configuration."""
|
||||||
|
from src.config import get_settings
|
||||||
|
settings = get_settings()
|
||||||
return {
|
return {
|
||||||
"base_url": "http://wiki:3000",
|
"base_url": f"http://{TEST_HOST}:3000",
|
||||||
"api_key": "test_api_key"
|
"username": settings.wikijs_username,
|
||||||
|
"password": settings.wikijs_password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def searxng_test_url() -> str:
|
def searxng_test_url() -> str:
|
||||||
"""Test SearXNG URL."""
|
"""Test SearXNG URL."""
|
||||||
return "http://searxng:8080"
|
return f"http://{TEST_HOST}:8080"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def ollama_test_config() -> dict:
|
def ollama_test_config() -> dict:
|
||||||
"""Test Ollama configuration."""
|
"""Test Ollama configuration."""
|
||||||
|
from src.config import get_settings
|
||||||
|
settings = get_settings()
|
||||||
return {
|
return {
|
||||||
"base_url": "http://ollama:11434",
|
"base_url": f"http://{TEST_HOST}:11434",
|
||||||
"model": "nomic-embed-text"
|
"model": settings.ollama_embedding_model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def redis_test_url() -> str:
|
def redis_test_url() -> str:
|
||||||
"""Test Redis URL."""
|
"""Test Redis URL."""
|
||||||
return "redis://redis-shared:6379/4"
|
return f"redis://{TEST_HOST}:6379/4"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ def settings():
|
|||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def neo4j_client(settings) -> AsyncGenerator[Neo4jClient, None]:
|
async def neo4j_client(settings, neo4j_test_uri) -> AsyncGenerator[Neo4jClient, None]:
|
||||||
"""Get connected Neo4j client."""
|
"""Get connected Neo4j client."""
|
||||||
client = Neo4jClient(
|
client = Neo4jClient(
|
||||||
uri=settings.neo4j_uri,
|
uri=neo4j_test_uri,
|
||||||
user=settings.neo4j_user,
|
user=settings.neo4j_user,
|
||||||
password=settings.neo4j_password
|
password=settings.neo4j_password
|
||||||
)
|
)
|
||||||
@@ -51,12 +51,12 @@ async def neo4j_client(settings) -> AsyncGenerator[Neo4jClient, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def wiki_client(settings) -> AsyncGenerator[WikiJSClient, None]:
|
async def wiki_client(wikijs_test_config) -> AsyncGenerator[WikiJSClient, None]:
|
||||||
"""Get Wiki.js client."""
|
"""Get Wiki.js client."""
|
||||||
client = WikiJSClient(
|
client = WikiJSClient(
|
||||||
base_url=settings.wikijs_url,
|
base_url=wikijs_test_config["base_url"],
|
||||||
username=settings.wikijs_username,
|
username=wikijs_test_config["username"],
|
||||||
password=settings.wikijs_password
|
password=wikijs_test_config["password"]
|
||||||
)
|
)
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
|||||||
+15
-12
@@ -43,10 +43,10 @@ def settings():
|
|||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def neo4j_client(settings) -> AsyncGenerator[Neo4jClient, None]:
|
async def neo4j_client(settings, neo4j_test_uri) -> AsyncGenerator[Neo4jClient, None]:
|
||||||
"""Get connected Neo4j client."""
|
"""Get connected Neo4j client."""
|
||||||
client = Neo4jClient(
|
client = Neo4jClient(
|
||||||
uri=settings.neo4j_uri,
|
uri=neo4j_test_uri,
|
||||||
user=settings.neo4j_user,
|
user=settings.neo4j_user,
|
||||||
password=settings.neo4j_password
|
password=settings.neo4j_password
|
||||||
)
|
)
|
||||||
@@ -56,32 +56,35 @@ async def neo4j_client(settings) -> AsyncGenerator[Neo4jClient, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def qdrant_client(settings) -> QdrantClientWrapper:
|
def qdrant_client(qdrant_test_url) -> QdrantClientWrapper:
|
||||||
"""Get Qdrant client."""
|
"""Get Qdrant client."""
|
||||||
return QdrantClientWrapper(url=settings.qdrant_url)
|
return QdrantClientWrapper(url=qdrant_test_url)
|
||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def wiki_client(settings) -> AsyncGenerator[WikiJSClient, None]:
|
async def wiki_client(wikijs_test_config) -> AsyncGenerator[WikiJSClient, None]:
|
||||||
"""Get Wiki.js client."""
|
"""Get Wiki.js client."""
|
||||||
client = WikiJSClient(
|
client = WikiJSClient(
|
||||||
base_url=settings.wikijs_url,
|
base_url=wikijs_test_config["base_url"],
|
||||||
username=settings.wikijs_username,
|
username=wikijs_test_config["username"],
|
||||||
password=settings.wikijs_password
|
password=wikijs_test_config["password"]
|
||||||
)
|
)
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def searxng_client(settings) -> SearXNGClient:
|
def searxng_client(searxng_test_url) -> SearXNGClient:
|
||||||
"""Get SearXNG client."""
|
"""Get SearXNG client."""
|
||||||
return SearXNGClient(base_url=settings.searxng_url)
|
return SearXNGClient(base_url=searxng_test_url)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def ollama_client(settings) -> OllamaClient:
|
def ollama_client(ollama_test_config) -> OllamaClient:
|
||||||
"""Get Ollama client."""
|
"""Get Ollama client."""
|
||||||
return OllamaClient(base_url=settings.ollama_url)
|
return OllamaClient(
|
||||||
|
base_url=ollama_test_config["base_url"],
|
||||||
|
model=ollama_test_config["model"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
+16
-15
@@ -30,10 +30,10 @@ def settings():
|
|||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def neo4j_client(settings) -> AsyncGenerator[Neo4jClient, None]:
|
async def neo4j_client(settings, neo4j_test_uri) -> AsyncGenerator[Neo4jClient, None]:
|
||||||
"""Get connected Neo4j client."""
|
"""Get connected Neo4j client."""
|
||||||
client = Neo4jClient(
|
client = Neo4jClient(
|
||||||
uri=settings.neo4j_uri,
|
uri=neo4j_test_uri,
|
||||||
user=settings.neo4j_user,
|
user=settings.neo4j_user,
|
||||||
password=settings.neo4j_password
|
password=settings.neo4j_password
|
||||||
)
|
)
|
||||||
@@ -43,45 +43,46 @@ async def neo4j_client(settings) -> AsyncGenerator[Neo4jClient, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def qdrant_client(settings) -> QdrantClientWrapper:
|
def qdrant_client(settings, qdrant_test_url) -> QdrantClientWrapper:
|
||||||
"""Get Qdrant client."""
|
"""Get Qdrant client."""
|
||||||
return QdrantClientWrapper(url=settings.qdrant_url)
|
return QdrantClientWrapper(url=qdrant_test_url)
|
||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def wikijs_client(settings) -> AsyncGenerator[WikiJSClient, None]:
|
async def wikijs_client(wikijs_test_config) -> AsyncGenerator[WikiJSClient, None]:
|
||||||
"""Get Wiki.js client."""
|
"""Get Wiki.js client."""
|
||||||
client = WikiJSClient(
|
client = WikiJSClient(
|
||||||
base_url=settings.wikijs_url,
|
base_url=wikijs_test_config["base_url"],
|
||||||
api_key=settings.wikijs_api_key
|
username=wikijs_test_config["username"],
|
||||||
|
password=wikijs_test_config["password"]
|
||||||
)
|
)
|
||||||
yield client
|
yield client
|
||||||
await client.close()
|
await client.close()
|
||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def searxng_client(settings) -> AsyncGenerator[SearXNGClient, None]:
|
async def searxng_client(searxng_test_url) -> AsyncGenerator[SearXNGClient, None]:
|
||||||
"""Get SearXNG client."""
|
"""Get SearXNG client."""
|
||||||
client = SearXNGClient(base_url=settings.searxng_url)
|
client = SearXNGClient(base_url=searxng_test_url)
|
||||||
yield client
|
yield client
|
||||||
await client.close()
|
await client.close()
|
||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def ollama_client(settings) -> AsyncGenerator[OllamaClient, None]:
|
async def ollama_client(ollama_test_config) -> AsyncGenerator[OllamaClient, None]:
|
||||||
"""Get Ollama client."""
|
"""Get Ollama client for embeddings."""
|
||||||
client = OllamaClient(
|
client = OllamaClient(
|
||||||
base_url=settings.ollama_url,
|
base_url=ollama_test_config["base_url"],
|
||||||
model=settings.ollama_model
|
model=ollama_test_config["model"]
|
||||||
)
|
)
|
||||||
yield client
|
yield client
|
||||||
await client.close()
|
await client.close()
|
||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def job_manager(settings) -> AsyncGenerator[JobManager, None]:
|
async def job_manager(redis_test_url) -> AsyncGenerator[JobManager, None]:
|
||||||
"""Get job manager."""
|
"""Get job manager."""
|
||||||
manager = JobManager(redis_url=settings.redis_url)
|
manager = JobManager(redis_url=redis_test_url)
|
||||||
await manager.connect()
|
await manager.connect()
|
||||||
yield manager
|
yield manager
|
||||||
await manager.close()
|
await manager.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user