test(oocana): add comprehensive tests for Context output/finish methods#466
test(oocana): add comprehensive tests for Context output/finish methods#466leavesster merged 2 commits intomainfrom
Conversation
- Test finish() with result, error, and empty cases - Test error takes priority over result in finish() - Test output() sends BlockOutput message - Test output() with undefined handle warns - Test outputs() sends batch BlockOutputs message - Test send_warning() and error() methods - Test property accessors (session_id, job_id, node_id, tmp_dir) - Test inputs_def and outputs_def are read-only
Summary by CodeRabbit发布说明
✏️ Tip: You can customize this high-level summary in your review settings. 概览为 Context 类添加全面的单元测试套件,涵盖 finish()、output()、send_warning()、error() 等方法,以及 session_id、job_id、node_id 等属性的行为验证,使用 mocked mainframe 作为依赖。 变更
预估代码审查工作量🎯 2 (简单) | ⏱️ ~10 分钟 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive unit tests for the Context class, which previously had zero test coverage despite being 912 lines long. The tests focus on core message-sending methods and property accessors.
Changes:
- Added 17 unit tests covering finish(), output(), outputs(), send_warning(), error(), send_message() methods
- Added tests for property accessors (session_id, job_id, node_id, tmp_dir, session_dir)
- Added tests verifying inputs_def and outputs_def are read-only properties
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| def tearDown(self): | ||
| """Clean up temporary directories.""" | ||
| import shutil |
There was a problem hiding this comment.
The tearDown method imports shutil inside the method rather than at the module level. For consistency with other imports (unittest.mock, tempfile, os) which are imported at the top, shutil should also be imported at the module level. This is a minor style issue but keeps imports consistent and makes dependencies clear.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Add 17 unit tests for Context class covering:
finish()with result, error, and empty casesfinish()output()sends BlockOutput messageoutput()with undefined handle warnsoutputs()sends batch BlockOutputs messagesend_warning()anderror()methodsinputs_defandoutputs_defare read-onlyProblem
Context class (912 lines) had zero test coverage for core methods.
Solution
Created
tests/test_context.pywith mocked Mainframe to test message sending behavior.Test Results
Files Added
tests/test_context.py(247 lines)