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

test: Status code indicates registration status #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions integration-tests/test_motd.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_motd(insights_client):
5. The MOTD file is still not present
"""
# If the system is not registered, the file should be present.
insights_client.run("--status")
insights_client.run("--status", check=False)
assert os.path.exists(MOTD_PATH)

# After registration, the file should not exist.
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_motd_dev_null(insights_client):
os.symlink(os.devnull, MOTD_PATH)
stack.callback(os.unlink, MOTD_PATH)

insights_client.run("--status")
insights_client.run("--status", check=False)
assert os.path.samefile(os.devnull, MOTD_PATH)

insights_client.register()
Expand Down
12 changes: 9 additions & 3 deletions integration-tests/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import contextlib
import pytest
from pytest_client_tools.util import Version
from time import sleep
import conftest

Expand Down Expand Up @@ -58,9 +59,11 @@ def test_status_unregistered(external_candlepin, insights_client):
2. Run `insights-client --status` command
:expectedresults:
1. The client unregisters successfully
2. If 'legacy_upload' is True return code is 1 and output contains
2. If 'legacy_upload' is True, return code is 1 and output contains
"Insights API says this machine is NOT registered."
If 'legacy_upload' is False return code is 0 and output contains
If 'legacy_upload' is False, on systems with version 3.5.3 and
higher, return code is 1 and output contains "This host is
unregistered.". Otherwise return code is 0 and output contains
"This host is unregistered."
"""
# running unregistration to ensure system is unregistered
Expand All @@ -76,5 +79,8 @@ def test_status_unregistered(external_candlepin, insights_client):
in registration_status.stdout
)
else:
assert registration_status.returncode == 0
if insights_client.core_version >= Version(3, 5, 3):
assert registration_status.returncode == 1
else:
assert registration_status.returncode == 0
assert "This host is unregistered.\n" == registration_status.stdout