test: 覆盖 cvpipe 拿框与多目录来源解析 - #44
Conversation
覆盖首次命名「流水线1」、递增跳过重名、保存失败返回 None
- CvService 多目录来源过滤/加载/保存(source 参数) - ContextVar 插件上下文裸名解析优先级 - cvpipe 拿框: 坐标合成、逐个验证第一个命中、判空返回 None - 更新 auto_save_pipeline 断言(source 参数)
Walkthrough新增测试覆盖 Changes流水线行为测试
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
test/one_dragon/base/cv_process/test_cv_service_multi_source.pytest/one_dragon_qt/logic/test_image_analysis_logic.py
| 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 |
There was a problem hiding this comment.
🎯 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.
| 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.
| 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 |
There was a problem hiding this comment.
🎯 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
实现并保留现有成功返回断言。
来自 fairy 的 PR。
内容
关联
主仓 PR: OneDragon-Anything/ZenlessZoneZero-OneDragon#2653
Summary by CodeRabbit