Skip to content
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

Fix useless asserts in installer tests #14099

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

rmynar
Copy link
Contributor

@rmynar rmynar commented Feb 16, 2024

Fixing assertions that were always True and therefore useless.

Note: bool("any string with non-zero length") is True, True or False is True

@rmynar rmynar added Easy Fix :) Easiest Fix to review and quick merge request. CherryPick PR needs CherryPick to previous branches 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 labels Feb 16, 2024
@rmynar rmynar requested a review from a team as a code owner February 16, 2024 14:37
@rmynar
Copy link
Contributor Author

rmynar commented Feb 16, 2024

trigger: test-robottelo
pytest: tests/foreman/ -k 'test_installer_sat_pub_directory_accessibility or test_installer_cap_pub_directory_accessibility'

@ogajduse
Copy link
Member

Good catch @rmynar! I have prepared a patch that adds flake8-simplify and flake8-return rulesets to our ruff linter config some time ago and seeing your patch made me publish it today. #14100

Let's merge yours first and I will rebase mine.

@ogajduse
Copy link
Member

@rmynar Can you please take a look at the PRT failures?

@rmynar
Copy link
Contributor Author

rmynar commented Feb 16, 2024

trigger: test-robottelo
pytest: tests/foreman/ -k "test_installer_sat_pub_directory_accessibility or test_installer_cap_pub_directory_accessibility"

Copy link
Member

@JacobCallahan JacobCallahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor recommendations

Comment on lines 66 to 67
accessibility_check = target_sat.execute(command).stdout.split('\r\n')
assert 'HTTP/1.1 200 OK' in accessibility_check or 'HTTP/2 200 ' in accessibility_check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're just checking for specific substrings, you likely don't need to bother splitting the output into a list.

Suggested change
accessibility_check = target_sat.execute(command).stdout.split('\r\n')
assert 'HTTP/1.1 200 OK' in accessibility_check or 'HTTP/2 200 ' in accessibility_check
accessibility_check = target_sat.execute(command).stdout
assert 'HTTP/1.1 200 OK' in accessibility_check or 'HTTP/2 200 ' in accessibility_check

Comment on lines 76 to 78
accessibility_check = target_sat.execute(command).stdout.split('\r\n')
assert 'HTTP/1.1 200 OK' not in accessibility_check
assert 'HTTP/2 200 ' not in accessibility_check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same recommendation here

Suggested change
accessibility_check = target_sat.execute(command).stdout.split('\r\n')
assert 'HTTP/1.1 200 OK' not in accessibility_check
assert 'HTTP/2 200 ' not in accessibility_check
accessibility_check = target_sat.execute(command).stdout
assert 'HTTP/1.1 200 OK' not in accessibility_check
assert 'HTTP/2 200 ' not in accessibility_check

Comment on lines 1758 to 1759
accessibility_check = capsule_configured.execute(command).stdout.split('\r\n')
assert 'HTTP/1.1 200 OK' in accessibility_check or 'HTTP/2 200 ' in accessibility_check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You get the idea

Suggested change
accessibility_check = capsule_configured.execute(command).stdout.split('\r\n')
assert 'HTTP/1.1 200 OK' in accessibility_check or 'HTTP/2 200 ' in accessibility_check
accessibility_check = capsule_configured.execute(command).stdout
assert 'HTTP/1.1 200 OK' in accessibility_check or 'HTTP/2 200 ' in accessibility_check

Comment on lines 1768 to 1770
accessibility_check = capsule_configured.execute(command).stdout.split('\r\n')
assert 'HTTP/1.1 200 OK' not in accessibility_check
assert 'HTTP/2 200 ' not in accessibility_check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Suggested change
accessibility_check = capsule_configured.execute(command).stdout.split('\r\n')
assert 'HTTP/1.1 200 OK' not in accessibility_check
assert 'HTTP/2 200 ' not in accessibility_check
accessibility_check = capsule_configured.execute(command).stdout
assert 'HTTP/1.1 200 OK' not in accessibility_check
assert 'HTTP/2 200 ' not in accessibility_check

@ogajduse
Copy link
Member

trigger: test-robottelo
pytest: tests/foreman/destructive/test_installer.py::test_installer_sat_pub_directory_accessibility tests/foreman/installer/test_installer.py::test_installer_cap_pub_directory_accessibility

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 5780
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/destructive/test_installer.py::test_installer_sat_pub_directory_accessibility tests/foreman/installer/test_installer.py::test_installer_cap_pub_directory_accessibility
Test Result : ================= 2 passed, 114 warnings in 2647.34s (0:44:07) =================

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Feb 16, 2024
Copy link
Contributor

@lhellebr lhellebr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Jacob, otherwise LGTM

@rmynar
Copy link
Contributor Author

rmynar commented Feb 19, 2024

I just wanted to fix the logical error in assertion, but you're right that the split was useless. Hopefully it looks better now

@rmynar rmynar requested a review from JacobCallahan February 19, 2024 14:21
Copy link
Member

@JacobCallahan JacobCallahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, thanks for the adjustment!

@JacobCallahan JacobCallahan merged commit 44ee8bf into SatelliteQE:master Feb 19, 2024
6 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 19, 2024
fix useless asserts

(cherry picked from commit 44ee8bf)
github-actions bot pushed a commit that referenced this pull request Feb 19, 2024
fix useless asserts

(cherry picked from commit 44ee8bf)
github-actions bot pushed a commit that referenced this pull request Feb 19, 2024
fix useless asserts

(cherry picked from commit 44ee8bf)
pondrejk pushed a commit that referenced this pull request Feb 20, 2024
Fix useless asserts in installer tests (#14099)

fix useless asserts

(cherry picked from commit 44ee8bf)

Co-authored-by: rmynar <[email protected]>
pondrejk pushed a commit that referenced this pull request Feb 20, 2024
Fix useless asserts in installer tests (#14099)

fix useless asserts

(cherry picked from commit 44ee8bf)

Co-authored-by: rmynar <[email protected]>
pondrejk pushed a commit that referenced this pull request Feb 20, 2024
Fix useless asserts in installer tests (#14099)

fix useless asserts

(cherry picked from commit 44ee8bf)

Co-authored-by: rmynar <[email protected]>
shweta83 pushed a commit to shweta83/robottelo that referenced this pull request Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 CherryPick PR needs CherryPick to previous branches Easy Fix :) Easiest Fix to review and quick merge request. PRT-Passed Indicates that latest PRT run is passed for the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants