Commit Graph

2 Commits

Author SHA1 Message Date
Chiguyong a4d3f227a6 refactor: 简化 __getattr__ 和测试 helper (ce-simplify-code)
core/exceptions.py:
- __getattr__ 用循环 + getattr 替代三处显式列举异常名
- 异常名只在 _LLM_EXCEPTION_NAMES 中定义一次,新增异常只改元组

test_memory_models.py:
- 提取 _assert_uuid_default/_assert_utc_default/_assert_unique_ids helper
- 消除 TestEpisodeModel 与 TestExperienceModel 间 3 个方法的复制粘贴

行为保持不变:52 tests passed,ruff clean,import 兼容性验证通过。
2026-07-06 23:20:23 +08:00
Chiguyong e0a22e0447 test: 补充 3 个高优先级测试缺口 (52 tests)
U2: tests/unit/llm/test_migration.py (6 tests)
  覆盖 migrate_api_keys_to_secrets 的 happy path/idempotent/empty/
  source missing/write failure/dual source 场景。mock SecretsStore 隔离 I/O。

U3: tests/unit/test_memory_models.py (31 tests)
  覆盖 EpisodeModel + ExperienceModel 的列类型/默认值/边界值。
  源文件是 SQLAlchemy ORM 模型(非 Pydantic),按 ORM 等价测试。
  跳过需 DB 连接的函数。

U4: tests/unit/test_chat_ws_routes.py (15 tests)
  覆盖 WebSocket /api/v1/chat/ws/{session_id} 的连接/认证/消息
  (ping/cancel/message/confirmation)/隔离/清理。mock _handle_chat_message。

所有测试通过,ruff 干净。预先存在的 OpenAICompatibleProvider 构造签名
和硬编码路径失败与本次改动无关。
2026-07-06 23:13:26 +08:00