第一批:上传去限制+进度展示、模板HTML预览+按需导出、检索TAB实时更新
第二批:edit护栏移除、导出按钮纯化+file_name落库、编辑失焦还原、
二次预览白底根治(防竞态+渲染兜底)
模板体系:7套公文模板(templates/)+templating渲染器、websearch联网
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""test_settings.py —— 限额常量与路径配置。"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
from vstore import settings
|
|
from vstore.settings import VstorePaths, get_fernet_key
|
|
|
|
|
|
def test_limits_match_brief():
|
|
"""2026-09-04:上传限制常量已移除(手工测试要求),保留结构常量。"""
|
|
assert settings.MAX_SECTIONS == 12
|
|
assert settings.MAX_OUTLINE_CHUNKS == 3
|
|
assert settings.EMBED_BODY_CAP == 200_000
|
|
assert settings.EMBED_DIM == 1024
|
|
for gone in ("MAX_ATTACH_COUNT", "MAX_ATTACH_BYTES", "MAX_ATTACH_CHARS"):
|
|
assert not hasattr(settings, gone), f"{gone} 应已移除"
|
|
|
|
|
|
def test_paths_default_derivation(tmp_path):
|
|
paths = VstorePaths(root=str(tmp_path))
|
|
assert paths.vault_path == str(tmp_path / "vault")
|
|
assert paths.index_path == str(tmp_path / "index")
|
|
|
|
|
|
def test_paths_explicit_override():
|
|
paths = VstorePaths(root="/x", vault_path="/v", index_path="http://h:1")
|
|
assert paths.vault_path == "/v"
|
|
assert paths.index_path == "http://h:1"
|
|
|
|
|
|
def test_embed_defaults():
|
|
assert settings.DEFAULT_EMBED_URL == "http://127.0.0.1:11434"
|
|
assert settings.DEFAULT_EMBED_MODEL == "bge-m3:567m"
|
|
|
|
|
|
def test_fernet_key_required(monkeypatch):
|
|
monkeypatch.delenv("VSTORE_KEY", raising=False)
|
|
with pytest.raises(RuntimeError):
|
|
get_fernet_key()
|
|
|
|
|
|
def test_fernet_key_ok(monkeypatch):
|
|
monkeypatch.setenv("VSTORE_KEY", "k" * 44)
|
|
assert get_fernet_key() == b"k" * 44
|