mirror of
https://github.com/insistence/RuoYi-Vue3-FastAPI.git
synced 2026-09-28 06:57:55 +00:00
* feat: 初始化插件系统 * refactor: 收口插件系统运行时重构 * perf: 优化插件系统类型提示 * fix&perf: 修复和优化插件系统 * fix: 修复gitignore规则误忽略插件文件的问题 * fix: 修复运行时插件根路径算错的问题 * fix: 加强插件发现和路由注册的防护措施 * revert: 回滚定时任务白名单 * fix: 移除未使用的应用路由注册探测 * revert: 恢复部分代码 * perf: 优化插件系统 * docs: 新增插件开发文档 * perf: 优化插件管理模块 * perf: 提升插件系统核心能力 * refactor: 重构生命周期 step runner * fix: 修复lint错误 * test: 清理测试用例 * test: 调整测试目录名称 * fix: 修复前后端目录硬编码的问题 * fix: 修复插件系统安全性缺口 * refactor: 重新设计插件生命周期 Migration 事务与回滚 * perf: 优化插件系统边界问题 * refactor: 重构当前插件系统的依赖体系设计 * perf: 优化代码 * perf: 优化代码 * fix: 修复代码合并问题 * fix: 修复bug * perf: 优化代码 * perf&fix: 优化代码和修复bug * docs: 优化文档格式 * feat: 适配Vue2版本 * docs: 更新README文档 * fix: 修复ruff lint错误 * chore: 更新后端依赖文件
53 lines
2.0 KiB
Python
53 lines
2.0 KiB
Python
import json
|
|
from pathlib import Path
|
|
|
|
from cli.groups.plugin.exporter import PluginCommandFileAdapter
|
|
|
|
|
|
def test_plugin_command_file_adapter_writes_markdown_file(tmp_path: Path) -> None:
|
|
"""校验插件命令文件适配器写入 Markdown 文件。"""
|
|
output_file = tmp_path / 'docs' / 'plugin.md'
|
|
|
|
payload = PluginCommandFileAdapter.write_markdown_file(
|
|
{'ok': True, 'markdown': '# Demo'},
|
|
str(output_file),
|
|
content_key='markdown',
|
|
failure_message='插件文档导出失败',
|
|
)
|
|
|
|
assert payload['ok'] is True
|
|
assert payload['exported'] is True
|
|
assert payload['outputFile'] == str(output_file)
|
|
assert output_file.read_text(encoding='utf-8') == '# Demo'
|
|
|
|
|
|
def test_plugin_command_file_adapter_writes_json_file(tmp_path: Path) -> None:
|
|
"""校验插件命令文件适配器写入 JSON 文件。"""
|
|
output_file = tmp_path / 'diagnose.json'
|
|
|
|
payload = PluginCommandFileAdapter.write_json_file(
|
|
{'ok': True, 'pluginId': 'demo'},
|
|
str(output_file),
|
|
failure_message='插件诊断包导出失败',
|
|
)
|
|
|
|
assert payload['exported'] is True
|
|
assert json.loads(output_file.read_text(encoding='utf-8')) == {'ok': True, 'pluginId': 'demo'}
|
|
|
|
|
|
def test_plugin_command_file_adapter_reads_config_import_values(tmp_path: Path) -> None:
|
|
"""校验插件命令文件适配器读取配置导入文件。"""
|
|
input_file = tmp_path / 'config.json'
|
|
input_file.write_text('{"values": {"enabled": true}}\n', encoding='utf-8')
|
|
|
|
payload = PluginCommandFileAdapter.read_config_import_file(str(input_file))
|
|
|
|
assert payload == {'ok': True, 'message': '配置导入文件读取完成', 'values': {'enabled': True}}
|
|
|
|
|
|
def test_plugin_command_file_adapter_reports_missing_config_import_file() -> None:
|
|
"""校验插件命令文件适配器报告缺少配置导入文件。"""
|
|
payload = PluginCommandFileAdapter.read_config_import_file('')
|
|
|
|
assert payload == {'ok': False, 'message': '导入配置必须指定 --input-file', 'values': {}}
|