-
Notifications
You must be signed in to change notification settings - Fork 2
Add new polarion tests #236
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
Conversation
Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com> Assisted-by: Claude code
WalkthroughAdds two new Polarion-focused test modules exercising CLI and helper flows, and raises coverage fail-under in pyproject.toml from 60 to 70. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
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 |
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
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: 1
🧹 Nitpick comments (2)
tests/polarion/test_polarion_set_automated_coverage.py (2)
387-406: Remove unused mock parameter.The
mock_approveparameter is not used in this test sincefind_polarion_idsreturns an empty list, meaningapprove_testsis never invoked.Apply this diff to remove the unnecessary mock:
@patch("apps.polarion.polarion_set_automated.get_polarion_project_id") @patch("apps.polarion.polarion_set_automated.find_polarion_ids") - @patch("apps.polarion.polarion_set_automated.approve_tests") @patch("apps.polarion.polarion_set_automated.remove_approved_tests") - def test_command_custom_config_file_path(self, mock_remove, mock_approve, mock_find, mock_get_project): + def test_command_custom_config_file_path(self, mock_remove, mock_find, mock_get_project):
411-435: Remove unused mock parameter.The
mock_approveparameter is not used in this test sincefind_polarion_idsreturns an empty list, meaningapprove_testsis never invoked.Apply this diff to remove the unnecessary mock:
@patch("apps.polarion.polarion_set_automated.get_polarion_project_id") @patch("apps.polarion.polarion_set_automated.find_polarion_ids") - @patch("apps.polarion.polarion_set_automated.approve_tests") @patch("apps.polarion.polarion_set_automated.remove_approved_tests") - def test_command_project_id_override_config(self, mock_remove, mock_approve, mock_find, mock_get_project): + def test_command_project_id_override_config(self, mock_remove, mock_find, mock_get_project):
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/polarion/test_polarion_set_automated_coverage.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/polarion/test_polarion_set_automated_coverage.py (1)
apps/polarion/polarion_set_automated.py (3)
approve_tests(15-19)polarion_approve_automate(59-95)remove_approved_tests(22-45)
🪛 Ruff (0.14.4)
tests/polarion/test_polarion_set_automated_coverage.py
357-357: Unpacked variable args is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
387-387: Unused method argument: mock_approve
(ARG002)
411-411: Unused method argument: mock_approve
(ARG002)
🔇 Additional comments (3)
tests/polarion/test_polarion_set_automated_coverage.py (3)
20-74: LGTM! Well-structured test coverage.The test methods follow best practices with clear AAA pattern, appropriate mocking, and comprehensive assertions on both return values and function call arguments.
76-174: LGTM! Excellent edge case coverage.The tests thoroughly cover the overlap logic between added and removed IDs (lines 89-92, 106), None handling, and various failure scenarios. The validation of set difference behavior is particularly well done.
1-435: Excellent test coverage overall!This test file provides comprehensive coverage of the polarion_set_automated module with well-structured tests following best practices. The tests effectively use mocking to isolate units under test, cover both success and failure paths, and validate edge cases like ID overlap logic and conditional execution flows.
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
♻️ Duplicate comments (1)
tests/polarion/test_polarion_set_automated_coverage.py (1)
333-361: Consider more robust path assertion.The test correctly validates config file usage, but line 360 uses
.endswith()which could be fragile if the default config path construction changes.Consider validating just the key components rather than the exact path suffix:
- assert kwargs["config_file_path"].endswith("/.config/python-utility-scripts/config.yaml") + assert ".config/python-utility-scripts/config.yaml" in kwargs["config_file_path"] + assert kwargs["config_file_path"].endswith("config.yaml")Note: Line 358's unused
argsvariable has been previously flagged for replacement with underscore.
🧹 Nitpick comments (1)
tests/polarion/test_polarion_set_automated_coverage.py (1)
106-106: Replace unused variable with underscore.The
argsvariable is unpacked but never used in the test.Apply this diff:
- args, kwargs = mock_update.call_args + _, kwargs = mock_update.call_args
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/polarion/test_polarion_set_automated_coverage.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/polarion/test_polarion_set_automated_coverage.py (1)
apps/polarion/polarion_set_automated.py (3)
approve_tests(15-19)polarion_approve_automate(59-95)remove_approved_tests(22-45)
🪛 Ruff (0.14.4)
tests/polarion/test_polarion_set_automated_coverage.py
106-106: Unpacked variable args is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
358-358: Unpacked variable args is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
388-388: Unused method argument: mock_approve
(ARG002)
412-412: Unused method argument: mock_approve
(ARG002)
🔇 Additional comments (6)
tests/polarion/test_polarion_set_automated_coverage.py (6)
20-74: Well-structured test coverage for approve_tests.The test class provides comprehensive coverage with clear test cases for success, partial failures, and empty input scenarios. Mock usage is appropriate and assertions verify both call arguments and return values.
114-175: Excellent edge case coverage.These tests thoroughly cover important edge cases including no removals, complete overlap with added IDs, None parameter handling, and failure scenarios. The test logic correctly validates the behavior of the
added_ids or []pattern and set difference operations.
188-295: Solid test coverage for command success and edge cases.These tests effectively validate:
- Successful execution flow with proper mock interactions
- Exit code 1 on both add and remove failures
- Missing required parameter handling
- Behavior when no added IDs are found (correctly verifying
approve_testsis not called)
299-331: Good verification of verbose logging behavior.The test correctly validates that the
--verboseflag enables DEBUG level logging for both the main logger and the utilities logger.
365-407: Comprehensive CLI configuration and failure testing.These tests provide excellent coverage of:
- Combined add/remove failure handling
- Custom config file path support
- Proper
get_polarion_project_idintegrationNote: The
mock_approveparameter at line 388 is flagged by Ruff as unused, but this is a false positive—it's required by the@patchdecorator stacking order (decorators apply bottom-up to function parameters).
408-436: Good validation of CLI parameter precedence.The test correctly verifies that
--project-idfrom the command line takes precedence over config file values, and thatget_polarion_project_idis not invoked when the CLI parameter is provided.Note: The
mock_approveparameter at line 412 is flagged by Ruff as unused, but this is a false positive—it's required by the@patchdecorator stacking order.
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: 8
♻️ Duplicate comments (1)
tests/polarion/test_polarion_set_automated_coverage.py (1)
358-361: Replace unused positional capture fromcall_args.Same Ruff warning as before—drop the unused positional tuple.
- args, kwargs = mock_get_project.call_args + _, kwargs = mock_get_project.call_args
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
pyproject.toml(1 hunks)tests/polarion/test_polarion_set_automated_coverage.py(1 hunks)tests/polarion/test_polarion_verify_tc_requirements_coverage.py(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- pyproject.toml
🧰 Additional context used
🧬 Code graph analysis (2)
tests/polarion/test_polarion_verify_tc_requirements_coverage.py (2)
apps/polarion/polarion_verify_tc_requirements.py (1)
has_verify(23-40)tests/polarion/test_polarion_set_automated_coverage.py (5)
setup_method(180-182)test_command_verbose_logging(299-330)test_command_uses_config_file_project_id(333-360)test_command_custom_config_file_path(388-406)test_command_project_id_override_config(412-436)
tests/polarion/test_polarion_set_automated_coverage.py (1)
apps/polarion/polarion_set_automated.py (3)
approve_tests(15-19)polarion_approve_automate(59-95)remove_approved_tests(22-45)
🪛 Ruff (0.14.4)
tests/polarion/test_polarion_verify_tc_requirements_coverage.py
63-63: Local variable result is assigned to but never used
Remove assignment to unused variable result
(F841)
153-153: Unpacked variable args is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
288-288: Local variable result is assigned to but never used
Remove assignment to unused variable result
(F841)
340-340: Local variable result is assigned to but never used
Remove assignment to unused variable result
(F841)
379-379: Local variable result is assigned to but never used
Remove assignment to unused variable result
(F841)
tests/polarion/test_polarion_set_automated_coverage.py
106-106: Unpacked variable args is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
358-358: Unpacked variable args is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
388-388: Unused method argument: mock_approve
(ARG002)
412-412: Unused method argument: mock_approve
(ARG002)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: can-be-merged
- GitHub Check: can-be-merged
- GitHub Check: python-module-install
- GitHub Check: tox
tests/polarion/test_polarion_verify_tc_requirements_coverage.py
Outdated
Show resolved
Hide resolved
tests/polarion/test_polarion_verify_tc_requirements_coverage.py
Outdated
Show resolved
Hide resolved
tests/polarion/test_polarion_verify_tc_requirements_coverage.py
Outdated
Show resolved
Hide resolved
tests/polarion/test_polarion_verify_tc_requirements_coverage.py
Outdated
Show resolved
Hide resolved
tests/polarion/test_polarion_verify_tc_requirements_coverage.py
Outdated
Show resolved
Hide resolved
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: 1
♻️ Duplicate comments (1)
tests/polarion/test_polarion_verify_tc_requirements_coverage.py (1)
153-153: Fix unused variable from unpacking.The
argsvariable is unpacked but never used. Replace it with_to indicate it's intentionally discarded.Apply this diff:
- args, kwargs = mock_get_project.call_args + _, kwargs = mock_get_project.call_args
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pyproject.toml(1 hunks)tests/polarion/test_polarion_verify_tc_requirements_coverage.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- pyproject.toml
🧰 Additional context used
🧬 Code graph analysis (1)
tests/polarion/test_polarion_verify_tc_requirements_coverage.py (2)
apps/polarion/polarion_verify_tc_requirements.py (1)
has_verify(23-40)tests/polarion/test_polarion_set_automated_coverage.py (5)
setup_method(180-182)test_command_verbose_logging(299-330)test_command_uses_config_file_project_id(333-360)test_command_custom_config_file_path(388-406)test_command_project_id_override_config(412-436)
🪛 Ruff (0.14.4)
tests/polarion/test_polarion_verify_tc_requirements_coverage.py
153-153: Unpacked variable args is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: can-be-merged
- GitHub Check: can-be-merged
- GitHub Check: python-module-install
- GitHub Check: tox
🔇 Additional comments (1)
tests/polarion/test_polarion_verify_tc_requirements_coverage.py (1)
1-21: LGTM! Well-structured test setup.The module docstring, imports, and test class setup follow best practices for testing Click commands with pytest.
tests/polarion/test_polarion_verify_tc_requirements_coverage.py
Outdated
Show resolved
Hide resolved
|
/approve |
|
/verified |
Assisted-by: Claude code
Summary by CodeRabbit