update test for enable/disable recommendations (IoP) - #20520
Conversation
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- In the final assertion, consider using the existing
OPENSSH_RECOMMENDATIONconstant instead of the hard-coded string'Decreased security: OpenSSH config permissions'to avoid duplication and keep the test resilient to future text changes. - Since you touched the surrounding comment, this is a good place to fix the typo
recommnedations→recommendationsfor clarity.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the final assertion, consider using the existing `OPENSSH_RECOMMENDATION` constant instead of the hard-coded string `'Decreased security: OpenSSH config permissions'` to avoid duplication and keep the test resilient to future text changes.
- Since you touched the surrounding comment, this is a good place to fix the typo `recommnedations` → `recommendations` for clarity.
## Individual Comments
### Comment 1
<location> `tests/foreman/ui/test_rhcloud_iop.py:344-349` </location>
<code_context>
- # Verify that Disabled recommnedations are 0
+ # Disable recommendation
+ session.recommendationstab.disable_recommendation_for_system(
+ recommendation_name=OPENSSH_RECOMMENDATION, hostname=rhel_insights_vm.hostname
+ )
+ # Verify that the disabled recommendation is filtered
result = session.recommendationstab.apply_filter("Status", "Disabled")
- assert 'No recommendations' in result[0]['Name']
+ assert 'Decreased security: OpenSSH config permissions' in result[0]['Name']
</code_context>
<issue_to_address>
**suggestion (testing):** Make the assertion on the disabled recommendations more robust than relying on the first list element
This assertion still assumes the expected recommendation is at `result[0]`. If multiple disabled recommendations are returned or ordering changes, the test may fail or give a false sense of correctness. Instead, assert that at least one item in `result` has the expected name, e.g. `assert any('Decreased security: OpenSSH config permissions' in r['Name'] for r in result)`, and optionally assert `len(result) > 0` to document the expectation that something is returned.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| session.recommendationstab.disable_recommendation_for_system( | ||
| recommendation_name=OPENSSH_RECOMMENDATION, hostname=rhel_insights_vm.hostname | ||
| ) | ||
| # Verify that the disabled recommendation is filtered | ||
| result = session.recommendationstab.apply_filter("Status", "Disabled") | ||
| assert 'No recommendations' in result[0]['Name'] | ||
| assert 'Decreased security: OpenSSH config permissions' in result[0]['Name'] |
There was a problem hiding this comment.
suggestion (testing): Make the assertion on the disabled recommendations more robust than relying on the first list element
This assertion still assumes the expected recommendation is at result[0]. If multiple disabled recommendations are returned or ordering changes, the test may fail or give a false sense of correctness. Instead, assert that at least one item in result has the expected name, e.g. assert any('Decreased security: OpenSSH config permissions' in r['Name'] for r in result), and optionally assert len(result) > 0 to document the expectation that something is returned.
d44222e to
c5ff1d7
Compare
|
trigger: test-robottelo |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The recommendation name
'Decreased security: OpenSSH config permissions'is hard-coded multiple times; consider using the existingOPENSSH_RECOMMENDATIONconstant (or another shared constant) to avoid duplication and keep the test resilient to name changes. - Before indexing
result[0]after applying filters, consider asserting thatresultis not empty to avoid potential index errors if the UI returns no rows.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The recommendation name `'Decreased security: OpenSSH config permissions'` is hard-coded multiple times; consider using the existing `OPENSSH_RECOMMENDATION` constant (or another shared constant) to avoid duplication and keep the test resilient to name changes.
- Before indexing `result[0]` after applying filters, consider asserting that `result` is not empty to avoid potential index errors if the UI returns no rows.
## Individual Comments
### Comment 1
<location> `tests/foreman/ui/test_rhcloud_iop.py:344-345` </location>
<code_context>
- assert 'No recommendations' in result[0]['Name']
+ assert 'Decreased security: OpenSSH config permissions' in result[0]['Name']
+
+ session.recommendationstab.enable_recommendation(
+ recommendation_name='Decreased security: OpenSSH config permissions'
+ )
+
</code_context>
<issue_to_address>
**suggestion:** Use the same recommendation identifier consistently (e.g. the `OPENSSH_RECOMMENDATION` constant) when enabling/disabling.
The disable path uses `OPENSSH_RECOMMENDATION`, but the enable path uses the raw string `'Decreased security: OpenSSH config permissions'`. If the constant changes, the test could disable one recommendation and try to enable another. Please use `OPENSSH_RECOMMENDATION` consistently (including in assertions), or derive the string from a single shared source.
Suggested implementation:
```python
# Verify that the disabled recommendation is filtered
result = session.recommendationstab.apply_filter("Status", "Disabled")
assert OPENSSH_RECOMMENDATION in result[0]['Name']
```
Search the rest of `tests/foreman/ui/test_rhcloud_iop.py` for any other hard-coded instances of `'Decreased security: OpenSSH config permissions'` and replace them with `OPENSSH_RECOMMENDATION` to keep the identifier consistent everywhere (including any other assertions or enable/disable calls).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
trigger: test-robottelo |
3 similar comments
|
trigger: test-robottelo |
|
trigger: test-robottelo |
|
trigger: test-robottelo |
|
moving to draft state until we get updated images in stage |
|
trigger: test-robottelo |
1 similar comment
|
trigger: test-robottelo |
8cbf806 to
b660a46
Compare
|
trigger: test-robottelo |
|
trigger: test-robottelo |
3 similar comments
|
trigger: test-robottelo |
|
trigger: test-robottelo |
|
trigger: test-robottelo |
|
trigger: test-robottelo |
1 similar comment
|
trigger: test-robottelo |
37a5bbb to
79e6291
Compare
Reviewer's GuideUpdates the IOP recommendations UI test to validate enabling/disabling a specific recommendation, adjusts the RHEL version marker, and aligns test metadata and expectations with the new behavior. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The recommendation name is sometimes taken from
OPENSSH_RECOMMENDATIONand sometimes hardcoded as'Decreased security: OpenSSH config permissions'; consider using a single source (e.g., the constant) for the name indisable_recommendation,enable_recommendation, and assertions to avoid drift if the text changes. - After re-enabling the recommendation, the initial
apply_filter("Status", "Enabled")call is not used and is immediately followed by anotherapply_filter; either assert on the first result or remove it (or add a clarifying comment) if it is only needed to reset filters.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The recommendation name is sometimes taken from `OPENSSH_RECOMMENDATION` and sometimes hardcoded as `'Decreased security: OpenSSH config permissions'`; consider using a single source (e.g., the constant) for the name in `disable_recommendation`, `enable_recommendation`, and assertions to avoid drift if the text changes.
- After re-enabling the recommendation, the initial `apply_filter("Status", "Enabled")` call is not used and is immediately followed by another `apply_filter`; either assert on the first result or remove it (or add a clarifying comment) if it is only needed to reset filters.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
79e6291 to
531146d
Compare
|
|
PRT Result |
|
Only 1 test |
531146d to
124ab14
Compare
|
|
PRT Result |
|
The PR is not about disable/enable IoP itself. I changed the PR title 😇 |
|
trigger: test-robottelo |
|
colehiggins (e) robo312 ~ projects robottelo 2 pytest tests/foreman/ui/test_rhcloud_iop.py::test_iop_recommendations_remediation_type_and_status tests/foreman/ui/test_rhcloud_iop.py . |
|
Test passing locally, Going to ask that we merge it in since PRT is failing but passing in jenkins |
* update test for enable disable iop * Fix failing tests and fixture * pre-commit * update pytest marker * add enable functionality to iop * update pytest marker * update test with new entity * update to rhel 10 for recommendations (cherry picked from commit 0b9ef3c)
* update test for enable disable iop * Fix failing tests and fixture * pre-commit * update pytest marker * add enable functionality to iop * update pytest marker * update test with new entity * update to rhel 10 for recommendations (cherry picked from commit 0b9ef3c)
* update test for enable disable iop * Fix failing tests and fixture * pre-commit * update pytest marker * add enable functionality to iop * update pytest marker * update test with new entity * update to rhel 10 for recommendations (cherry picked from commit 0b9ef3c)
Test for disabling/enabling recommendations on IOP.
SAT-38139
SatelliteQE/airgun#2247
Summary by Sourcery
Update IOP recommendations UI test to validate disabling and re-enabling a specific recommendation on supported RHEL versions.
Enhancements:
Tests: