-
Notifications
You must be signed in to change notification settings - Fork 21
Use mock to avoid pre-checks for device add methods #1248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use mock to avoid pre-checks for device add methods #1248
Conversation
19b2dde to
c44a177
Compare
This will allow coverage in some unusual error paths. Signed-off-by: mulhern <amulhern@redhat.com>
c44a177 to
4bd1e23
Compare
|
/packit build |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThese changes remove pragma comments from pool device operations and add tests validating that adding duplicate devices raises an error, covering both data and cache device scenarios. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Pre-merge checks and finishing touches✅ Passed checks (3 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/integration/pool/test_add.py (1)
128-128: Consider using unpacking operator for list concatenation.Static analysis suggests using the unpacking operator for better readability and performance.
🔎 Proposed refactor
Line 128:
- command_line = self._MENU + [self._POOLNAME] + self._DEVICES + command_line = [*self._MENU, self._POOLNAME, *self._DEVICES]Line 261:
- command_line = self._MENU + [self._POOLNAME] + devices + command_line = [*self._MENU, self._POOLNAME, *devices]Also applies to: 261-261
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/stratis_cli/_actions/_pool.pytests/integration/pool/test_add.py
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-18T15:25:05.145Z
Learnt from: mulkieran
Repo: stratis-storage/stratis-cli PR: 0
File: :0-0
Timestamp: 2025-08-18T15:25:05.145Z
Learning: For the stratis-cli project, use Python's standard unittest framework instead of pytest. The codebase follows unittest.TestCase patterns with standard unittest assertions and test discovery.
Applied to files:
tests/integration/pool/test_add.py
🪛 Ruff (0.14.10)
tests/integration/pool/test_add.py
128-128: Consider [*self._MENU, self._POOLNAME, *self._DEVICES] instead of concatenation
Replace with [*self._MENU, self._POOLNAME, *self._DEVICES]
(RUF005)
261-261: Consider [*self._MENU, self._POOLNAME, *devices] instead of concatenation
Replace with [*self._MENU, self._POOLNAME, *devices]
(RUF005)
🔇 Additional comments (4)
src/stratis_cli/_actions/_pool.py (1)
553-553: LGTM! Error paths now covered by tests.The removal of
# pragma: no covercomments is appropriate since the new mocked tests intest_add.pynow exercise these error-handling paths.Also applies to: 608-608
tests/integration/pool/test_add.py (3)
18-19: LGTM! Necessary imports for mocking tests.The additions of
patchfromunittest.mockandStratisCliIncoherenceErrorare required for the new test cases that mock pre-checks to exercise error paths.Also applies to: 28-28
121-139: LGTM! Test exercises previously uncovered error path.The test correctly mocks
_check_same_tierto bypass pre-checks, allowing the code to attempt adding duplicate devices and trigger theStratisCliIncoherenceErrorat line 553 in_pool.py. The use ofautospec=Trueensures the mock respects the function signature.
253-274: LGTM! Test exercises previously uncovered error path.The test correctly mocks
_check_same_tierto bypass pre-checks, allowing the code to attempt adding duplicate cache devices and trigger theStratisCliIncoherenceErrorat line 608 in_pool.py. The use ofautospec=Trueensures the mock respects the function signature.
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
No description provided.