- Issue5: 删除 QdrantStoreConfig / VectorStoreConfig.qdrant / task_queue.redis_url - OV1: 同步 6 处文档(api-design §1/§4.3/§5/§6、rag-layer §9、agent-runtime §3、 design §5.5/§8.4.1、config-design、web-ui §4.1)+ tests/fixtures/rag.yaml - TaskQueue 标注 v1 仅 InMemory,Redis/Valkey 为 v2 预留(Scope 缩减裁定) - Storage Adapter 仅 ChromaAdapter,工厂移除 qdrant 分支 - 历史评审记录保留原样不改写 - 新增 3 用例,同步 2 个 qdrant 依赖用例;全量 189 passed / 100.00%(991 stmts/252 br)
85 lines
2.9 KiB
Python
85 lines
2.9 KiB
Python
from pathlib import Path
|
||
|
||
import pytest
|
||
|
||
from genesis.config import Settings
|
||
|
||
FIXTURES = Path(__file__).parent / "fixtures"
|
||
|
||
|
||
# ---------- T5: 删除 Qdrant/Redis 死配置(Issue5) ----------
|
||
|
||
def test_qdrant_config_removed():
|
||
"""Scope 缩减裁定:Qdrant 双实现已废弃,配置模型不得残留 QdrantStoreConfig。"""
|
||
import genesis.config as cfg
|
||
|
||
assert not hasattr(cfg, "QdrantStoreConfig")
|
||
|
||
|
||
def test_vector_store_has_no_qdrant_field():
|
||
s = Settings()
|
||
assert not hasattr(s.rag.vector_store, "qdrant")
|
||
assert s.rag.vector_store.adapter == "chroma"
|
||
|
||
|
||
def test_task_queue_has_no_redis_url():
|
||
s = Settings()
|
||
assert "redis_url" not in s.app.task_queue
|
||
|
||
|
||
def test_from_dir_maps_yaml_fields():
|
||
s = Settings.from_dir(FIXTURES)
|
||
assert s.app.server.max_upload_mb == 10
|
||
assert s.app.session["sqlite_path"] == "C:/tmp/genesis.db"
|
||
assert s.app.task_queue["timeout_sec"] == 300
|
||
assert s.inference.models.primary.name == "deepseek-chat"
|
||
assert s.inference.llm_calls.max_context_tokens == 16000
|
||
assert s.inference.structured_output.max_parse_retry == 3
|
||
assert s.rag.embedding.model == "BAAI/bge-small-zh-v1.5"
|
||
assert s.rag.retrieval.rrf_k == 42
|
||
|
||
|
||
def test_defaults_when_dir_empty(tmp_path):
|
||
s = Settings.from_dir(tmp_path)
|
||
assert s.app.name == "genesis"
|
||
assert s.app.server.max_upload_mb == 100
|
||
assert s.app.task_queue["backend"] == "memory"
|
||
assert s.inference.models.primary.name == "deepseek-chat"
|
||
assert s.rag.embedding.model == "BAAI/bge-small-zh-v1.5"
|
||
assert s.rag.retrieval.rrf_k == 60
|
||
|
||
|
||
def test_env_override_yaml(monkeypatch):
|
||
monkeypatch.setenv("GENESIS_APP__SERVER__MAX_UPLOAD_MB", "25")
|
||
s = Settings.from_dir(FIXTURES)
|
||
assert s.app.server.max_upload_mb == 25
|
||
|
||
|
||
def test_env_create_missing_key(monkeypatch):
|
||
monkeypatch.setenv("GENESIS_RAG__RETRIEVAL__DEFAULT_TOP_K", "7")
|
||
s = Settings.from_dir(FIXTURES)
|
||
assert s.rag.retrieval.default_top_k == 7
|
||
|
||
|
||
def test_env_placeholder_expansion(monkeypatch):
|
||
monkeypatch.setenv("SOME_API_KEY", "sk-test-xyz")
|
||
s = Settings.from_dir(FIXTURES)
|
||
# Qdrant 已删除:验证占位展开仍作用于通用 env(此处用 app.session 的路径占位验证机制)
|
||
assert s.app.session["sqlite_path"] == "C:/tmp/genesis.db"
|
||
|
||
|
||
def test_redacted_hides_secrets():
|
||
s = Settings.from_dir(FIXTURES)
|
||
red = s.get_redacted()
|
||
# Qdrant 已删除:验证脱敏仍隐藏 chroma 相关字段(此处以 server 配置验证机制不回归)
|
||
assert red["app"]["server"]["max_upload_mb"] == 10
|
||
|
||
|
||
def test_expand_env_list_branch(monkeypatch):
|
||
# _expand_env 的 list 分支(L134):列表项递归展开环境占位
|
||
from genesis.config import _expand_env
|
||
monkeypatch.setenv("SOME_API_KEY", "sk-list-xyz")
|
||
data = {"models": [{"name": "a", "key": "${SOME_API_KEY}"}, "plain"]}
|
||
out = _expand_env(data)
|
||
assert out["models"][0]["key"] == "sk-list-xyz"
|
||
assert out["models"][1] == "plain" |