Files
cmshoppe/tests/test_module_contracts.py
T
chengma aba272dd21 test: 建立单元测试基座
- 新增 unittest tests 基座,覆盖 appconfig 与 db 纯逻辑

- 增加 excel/prompts 未实现模块的契约占位测试

- 补强 config.json 对 *_token 与 *_password 的敏感字段拦截

- 更新任务看板、当前状态、API 合约和进度记录
2026-06-27 09:17:20 +08:00

44 lines
1.2 KiB
Python

import importlib
import importlib.util
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(__file__))
from _helpers import REPO_ROOT
if str(REPO_ROOT) not in sys.path:
sys.path.insert(0, str(REPO_ROOT))
def import_or_skip(module_name):
if importlib.util.find_spec(module_name) is None:
raise unittest.SkipTest(f"{module_name} 尚未实现")
return importlib.import_module(module_name)
class PendingModuleContractTests(unittest.TestCase):
def test_excel_contract_when_module_exists(self):
excel = import_or_skip("app.excel")
for name in ("import_tasks", "match_summary", "write_back", "export_copy"):
self.assertTrue(callable(getattr(excel, name, None)), name)
def test_prompts_contract_when_module_exists(self):
prompts = import_or_skip("app.prompts")
for name in (
"load_title_prompt",
"save_title_prompt",
"list_cover_templates",
"load_cover_template",
"save_cover_template",
"rename_cover_template",
"delete_cover_template",
"render_prompt",
):
self.assertTrue(callable(getattr(prompts, name, None)), name)
if __name__ == "__main__":
unittest.main()