-
Notifications
You must be signed in to change notification settings - Fork 131
update test for enable disable iop #20520
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
base: master
Are you sure you want to change the base?
update test for enable disable iop #20520
Conversation
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.
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.
tests/foreman/ui/test_rhcloud_iop.py
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
1 similar comment
|
trigger: test-robottelo |
Test for disabling/enabling recommendations on IOP.
SAT-38139
SatelliteQE/airgun#2247