Skip to content

test(plugin): 覆盖集合来源多插件导入 - #61

Open
ShadowLemoon wants to merge 1 commit into
mainfrom
feat/plugins-manage
Open

test(plugin): 覆盖集合来源多插件导入#61
ShadowLemoon wants to merge 1 commit into
mainfrom
feat/plugins-manage

Conversation

@ShadowLemoon

Copy link
Copy Markdown
Collaborator

为什么改

OneDragon-Anything/ZenlessZoneZero-OneDragon#2097 的集合 ZIP、松散集合目录导入与第三方插件扫描边界提供配套回归测试。

改动要点

  • 覆盖集合 ZIP 与集合目录的多插件预览、安装、重复名称拒绝和选择性覆盖
  • 覆盖单插件失败隔离、覆盖回滚与解压总体积限制
  • 覆盖第三方插件仅扫描插件根第一层 factory
  • 覆盖目录和 factory 文件符号链接、越界链接及多节点目录链接环
  • 覆盖 GUI 按来源路径与插件名匹配覆盖目标

关联

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • 测试
    • 新增插件目录扫描、导入、预览与删除场景的全面测试。
    • 覆盖路径安全、符号链接、重复命名、冲突处理、失败回滚及多插件隔离。
    • 验证内置应用递归发现与第三方插件目录扫描规则。
    • 新增已安装插件识别、版本解析和插件信息匹配测试。

Walkthrough

新增插件导入服务、应用工厂扫描和已安装插件映射测试。测试覆盖目录与压缩包导入、路径安全、符号链接、回滚、批量处理及元数据解析。

Changes

插件预览与测试夹具

Layer / File(s) Summary
插件预览与测试夹具
test/one_dragon/base/operation/application/plugin_import_service/conftest.py, test/one_dragon/base/operation/application/plugin_import_service/test_preview_plugin.py
新增测试桩、临时插件目录夹具和 ZIP 创建夹具。预览测试覆盖包装目录、工厂目录、重复路径、常量文件位置和多插件元数据读取。

目录导入与删除安全

Layer / File(s) Summary
目录导入与删除安全
test/one_dragon/base/operation/application/plugin_import_service/test_delete_plugin.py, test/one_dragon/base/operation/application/plugin_import_service/test_import_directory.py
覆盖插件目录边界校验、目录删除、嵌套目录、重复名称、选择性覆盖、符号链接、复制失败回滚和批量失败隔离。

压缩包导入生命周期

Layer / File(s) Summary
压缩包导入生命周期
test/one_dragon/base/operation/application/plugin_import_service/test_import_plugin.py
覆盖插件根目录识别、路径穿越、重复路径、常量文件校验、解压体积限制、目标冲突、回滚、多插件导入和部分失败隔离。

应用发现与已安装插件映射

Layer / File(s) Summary
应用发现与已安装插件映射
test/one_dragon/base/operation/application/application_factory_manager/test_scan_directory.py, test/zzz_od/gui/view/setting/setting_plugin_interface/test_get_installed_plugins_by_package.py
覆盖第三方和内置应用工厂扫描范围、符号链接过滤、插件目录选择、版本比较及源路径与插件名组合键。

Estimated code review effort: 4 (Complex) | ~45 minutes

Poem

兔子捧来测试包,
路径安全逐项查。
ZIP 展开不越界,
失败回滚旧家。
符号链接轻轻拦,
工厂扫描开新花。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了集合来源的多插件导入测试,且与变更内容直接相关。
Description check ✅ Passed 描述明确说明了多插件导入、插件扫描边界和 GUI 覆盖匹配等测试范围,与变更内容一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/plugins-manage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/one_dragon/base/operation/application/plugin_import_service/test_import_plugin.py (1)

286-293: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

故障注入替身耦合私有临时目录命名前缀。 两处替身都用 .<插件名>.tmp- 前缀判断是否抛出异常,并且没有断言注入确实触发。如果生产代码更改临时目录命名,条件永不命中,导入会正常成功,回滚与隔离断言会静默失效。

  • test/one_dragon/base/operation/application/plugin_import_service/test_import_plugin.py#L286-L293:在 fail_staging_replace 中记录注入标志,并在断言块补充 assert triggered
  • test/one_dragon/base/operation/application/plugin_import_service/test_import_plugin.py#L471-L484:在 fail_brokenfail_broken_cleanup 中记录注入标志,并在断言块确认两者均已触发。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@test/one_dragon/base/operation/application/plugin_import_service/test_import_plugin.py`
around lines 286 - 293, 更新
test/one_dragon/base/operation/application/plugin_import_service/test_import_plugin.py
的 286-293 行,在 fail_staging_replace 中记录是否实际触发异常,并在对应断言块增加 assert triggered;同时更新
471-484 行的 fail_broken 与
fail_broken_cleanup,分别记录触发状态,并在断言块确认两者均已触发,避免仅依赖临时目录命名前缀而导致故障注入静默失效。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@test/one_dragon/base/operation/application/plugin_import_service/test_import_plugin.py`:
- Around line 286-293: 更新
test/one_dragon/base/operation/application/plugin_import_service/test_import_plugin.py
的 286-293 行,在 fail_staging_replace 中记录是否实际触发异常,并在对应断言块增加 assert triggered;同时更新
471-484 行的 fail_broken 与
fail_broken_cleanup,分别记录触发状态,并在断言块确认两者均已触发,避免仅依赖临时目录命名前缀而导致故障注入静默失效。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d598890-5c7a-4373-a544-7c7060225b7e

📥 Commits

Reviewing files that changed from the base of the PR and between d1cd794 and a492f6f.

📒 Files selected for processing (7)
  • test/one_dragon/base/operation/application/application_factory_manager/test_scan_directory.py
  • test/one_dragon/base/operation/application/plugin_import_service/conftest.py
  • test/one_dragon/base/operation/application/plugin_import_service/test_delete_plugin.py
  • test/one_dragon/base/operation/application/plugin_import_service/test_import_directory.py
  • test/one_dragon/base/operation/application/plugin_import_service/test_import_plugin.py
  • test/one_dragon/base/operation/application/plugin_import_service/test_preview_plugin.py
  • test/zzz_od/gui/view/setting/setting_plugin_interface/test_get_installed_plugins_by_package.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant