dev-0.9.x -> main #81

Merged
alpha-nerd merged 2 commits from dev-0.9.x into main 2026-05-17 11:30:52 +02:00
3 changed files with 13 additions and 4 deletions
Showing only changes of commit 0b64a84e96 - Show all commits

View file

@ -10,6 +10,4 @@ api_keys:
"http://192.168.0.51:12434": "ollama" "http://192.168.0.51:12434": "ollama"
"http://192.168.0.51:12434/v1": "llama" "http://192.168.0.51:12434/v1": "llama"
db_path: "/tmp/nomyo_test_tokens.db"
cache_enabled: false cache_enabled: false

View file

@ -16,6 +16,7 @@ import asyncio
import os import os
import ssl import ssl
import sys import sys
import tempfile
from pathlib import Path from pathlib import Path
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
@ -24,8 +25,14 @@ import httpx
import pytest import pytest
_TEST_DIR = Path(__file__).parent _TEST_DIR = Path(__file__).parent
# Must be set before importing router so the module-level Config.from_yaml uses test config # Must be set before importing router so module-level Config.from_yaml + Config field
# defaults pick these up. db_path is intentionally absent from config_test.yaml so the
# env-var default wins — keeps tests portable across CI runners (Linux/macOS/Windows).
os.environ.setdefault("NOMYO_ROUTER_CONFIG_PATH", str(_TEST_DIR / "config_test.yaml")) os.environ.setdefault("NOMYO_ROUTER_CONFIG_PATH", str(_TEST_DIR / "config_test.yaml"))
os.environ.setdefault(
"NOMYO_ROUTER_DB_PATH",
str(Path(tempfile.gettempdir()) / "nomyo_router_test_tokens.db"),
)
sys.path.insert(0, str(_TEST_DIR.parent)) sys.path.insert(0, str(_TEST_DIR.parent))

View file

@ -1,4 +1,6 @@
"""Unit tests for cache.LLMCache in exact-match mode (no sentence-transformers needed).""" """Unit tests for cache.LLMCache in exact-match mode (no sentence-transformers needed)."""
import tempfile
from pathlib import Path
from types import SimpleNamespace from types import SimpleNamespace
import orjson import orjson
@ -13,6 +15,8 @@ from cache import (
openai_nonstream_to_sse, openai_nonstream_to_sse,
) )
_CACHE_DB_PATH = str(Path(tempfile.gettempdir()) / "nomyo_test_cache.db")
def _exact_cfg(backend: str = "memory") -> SimpleNamespace: def _exact_cfg(backend: str = "memory") -> SimpleNamespace:
"""Config for exact-match mode — similarity=1.0 avoids embedding deps.""" """Config for exact-match mode — similarity=1.0 avoids embedding deps."""
@ -22,7 +26,7 @@ def _exact_cfg(backend: str = "memory") -> SimpleNamespace:
cache_similarity=1.0, cache_similarity=1.0,
cache_history_weight=0.3, cache_history_weight=0.3,
cache_ttl=300, cache_ttl=300,
cache_db_path="/tmp/test_cache.db", cache_db_path=_CACHE_DB_PATH,
cache_redis_url="redis://localhost:6379", cache_redis_url="redis://localhost:6379",
) )