Skip to content

test: 覆盖 cvpipe 拿框与多目录来源解析 - #44

Open
kawayiYokami wants to merge 2 commits into
OneDragon-Anything:mainfrom
kawayiYokami:feat/optimize-cv-pipeline
Open

test: 覆盖 cvpipe 拿框与多目录来源解析#44
kawayiYokami wants to merge 2 commits into
OneDragon-Anything:mainfrom
kawayiYokami:feat/optimize-cv-pipeline

Conversation

@kawayiYokami

@kawayiYokami kawayiYokami commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

来自 fairy 的 PR。

内容

  • CvService 多目录来源过滤/加载/保存(source 参数)
  • ContextVar 插件上下文裸名解析优先级
  • cvpipe 拿框:坐标合成、逐个验证第一个命中、判空返回 None
  • 更新 auto_save_pipeline 断言(source 参数)

关联

主仓 PR: OneDragon-Anything/ZenlessZoneZero-OneDragon#2653

Summary by CodeRabbit

  • 测试
    • 新增多来源图像识别流水线测试,覆盖主仓库与插件目录中的名称查询、来源加载、上下文优先解析及保存。
    • 新增区域取框与 OCR 校验测试,覆盖坐标合成、验证失败及流水线执行失败场景。
    • 新增自动保存测试,验证名称生成、跳过重复名称,以及保存失败时保持当前名称不变。

覆盖首次命名「流水线1」、递增跳过重名、保存失败返回 None
- CvService 多目录来源过滤/加载/保存(source 参数)
- ContextVar 插件上下文裸名解析优先级
- cvpipe 拿框: 坐标合成、逐个验证第一个命中、判空返回 None
- 更新 auto_save_pipeline 断言(source 参数)
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

新增测试覆盖 CvService 多来源流水线解析、插件目录保存、cvpipe 取框验证,以及 ImageAnalysisLogic 自动保存流水线名称和失败状态。

Changes

流水线行为测试

Layer / File(s) Summary
CvService 多来源与取框验证
test/one_dragon/base/cv_process/test_cv_service_multi_source.py
验证主仓与插件目录的名称隔离、显式来源加载、插件上下文解析、插件目录保存,以及 cvpipe 候选框偏移、OCR 匹配和失败返回。
图像分析自动保存
test/one_dragon_qt/logic/test_image_analysis_logic.py
验证自动生成首个可用名称、跳过已存在名称,以及保存失败时返回 None 并保持当前激活名称。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

兔子捧着测试跑,
插件主仓都查到。
框框偏移配 OCR,
名称重复就跳过。
保存失败状态稳,
新增覆盖乐淘淘。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了 PR 对 cvpipe 取框和多目录来源解析测试的主要变更。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@test/one_dragon_qt/logic/test_image_analysis_logic.py`:
- Around line 42-49: Update the auto_save_pipeline test around
logic.auto_save_pipeline so active_pipeline_name starts with an existing
non-None name before simulating save failure. Assert that the returned name is
None while logic.active_pipeline_name remains the original name, ensuring failed
saves preserve the existing active pipeline.

In `@test/one_dragon/base/cv_process/test_cv_service_multi_source.py`:
- Around line 54-58: 增强
test/one_dragon/base/cv_process/test_cv_service_multi_source.py
第54-58行的测试,记录文件探测路径并断言 source='test_plugin'
时只探测插件流水线目录;同时更新第66-82行的测试,使主仓和插件路径均存在,断言插件路径先被读取且命中插件后不再回退主仓。围绕 load_pipeline
实现并保留现有成功返回断言。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2f015166-5f41-4e46-866f-b6efee4b26bf

📥 Commits

Reviewing files that changed from the base of the PR and between bb8d9ac and 8decca8.

📒 Files selected for processing (2)
  • test/one_dragon/base/cv_process/test_cv_service_multi_source.py
  • test/one_dragon_qt/logic/test_image_analysis_logic.py

Comment on lines +42 to +49
logic = _create_logic()
logic.active_pipeline_name = None
logic.cv_service.save_pipeline.return_value = False

name = logic.auto_save_pipeline()

assert name is None
assert logic.active_pipeline_name is None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

验证保存失败时保留已有活动流水线名称。

当前测试将 active_pipeline_name 设为 None。如果实现错误地在保存失败时将其清空为 None,测试仍会通过。

将初始值设为已有名称,并断言失败后该名称不变。

建议修改
-    logic.active_pipeline_name = None
+    logic.active_pipeline_name = '已有流水线'
@@
-    assert logic.active_pipeline_name is None
+    assert logic.active_pipeline_name == '已有流水线'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logic = _create_logic()
logic.active_pipeline_name = None
logic.cv_service.save_pipeline.return_value = False
name = logic.auto_save_pipeline()
assert name is None
assert logic.active_pipeline_name is None
logic = _create_logic()
logic.active_pipeline_name = '已有流水线'
logic.cv_service.save_pipeline.return_value = False
name = logic.auto_save_pipeline()
assert name is None
assert logic.active_pipeline_name == '已有流水线'
🤖 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_qt/logic/test_image_analysis_logic.py` around lines 42 - 49,
Update the auto_save_pipeline test around logic.auto_save_pipeline so
active_pipeline_name starts with an existing non-None name before simulating
save failure. Assert that the returned name is None while
logic.active_pipeline_name remains the original name, ensuring failed saves
preserve the existing active pipeline.

Comment on lines +54 to +58
with patch('os.path.exists', return_value=True), \
patch('builtins.open', MagicMock()), \
patch('one_dragon.base.cv_process.cv_service.yaml_utils.safe_load', return_value=None):
pipeline = service.load_pipeline('b', source='test_plugin')
assert pipeline is not None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

使来源解析测试区分目录并验证优先级。

这两个测试只验证 load_pipeline 返回非 None。错误的主仓回退或主仓优先实现也可以通过测试。

  • test/one_dragon/base/cv_process/test_cv_service_multi_source.py#L54-L58:记录探测路径,并断言 source='test_plugin' 时只探测 test_plugin 的流水线目录。
  • test/one_dragon/base/cv_process/test_cv_service_multi_source.py#L66-L82:使主仓和插件路径都存在,并断言插件路径先被读取;插件命中后不应回退主仓。
📍 Affects 1 file
  • test/one_dragon/base/cv_process/test_cv_service_multi_source.py#L54-L58 (this comment)
  • test/one_dragon/base/cv_process/test_cv_service_multi_source.py#L66-L82
🤖 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/cv_process/test_cv_service_multi_source.py` around lines
54 - 58, 增强 test/one_dragon/base/cv_process/test_cv_service_multi_source.py
第54-58行的测试,记录文件探测路径并断言 source='test_plugin'
时只探测插件流水线目录;同时更新第66-82行的测试,使主仓和插件路径均存在,断言插件路径先被读取且命中插件后不再回退主仓。围绕 load_pipeline
实现并保留现有成功返回断言。

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