Skip to content

Commit

Permalink
test: Added integration test for rhc status --format json
Browse files Browse the repository at this point in the history
* Card ID: CCT-945
* Added one test of the case, when status command is used
  with --format json. It checks that output is in JSON format
  and it includes all attributes
  • Loading branch information
jirihnidek authored and Archana-PandeyM committed Dec 2, 2024
1 parent a82ba71 commit 9dc70c1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions integration-tests/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import pytest
import json
from pytest_client_tools import util
from utils import yggdrasil_service_is_active

Expand Down Expand Up @@ -34,6 +35,32 @@ def test_status_connected(external_candlepin, rhc, test_config):
assert "The yggdrasil service is active" in status_result.stdout


def test_status_connected_format_json(external_candlepin, rhc, test_config):
"""
Test 'rhc status --format json' command, when host is connected
test_steps:
1 - rhc connect
2 - rhc status
expected_output:
1 - Validate that output is valid JSON document
2 - Validate that JSON document contains expected data
"""
rhc.connect(
username=test_config.get("candlepin.username"),
password=test_config.get("candlepin.password")
)
status_result = rhc.run("status", "--format", "json", check=False)
assert status_result.returncode == 0
status_json = json.loads(status_result.stdout)
assert "hostname" in status_json
assert "rhsm_connected" in status_json
assert type(status_json["rhsm_connected"]) == bool
assert "insights_connected" in status_json
assert type(status_json["insights_connected"]) == bool
assert "yggdrasil_running" in status_json
assert type(status_json["yggdrasil_running"]) == bool


def test_status_disconnected(rhc):
"""Test RHC Status command when the host is disconnected.
Ref: https://issues.redhat.com/browse/CCT-525
Expand Down

0 comments on commit 9dc70c1

Please sign in to comment.