Skip to content
Merged
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
2 changes: 1 addition & 1 deletion tests/aignostics/application/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def test_cli_run_submit_fails_when_system_unhealthy_and_no_force(


@pytest.mark.e2e
@pytest.mark.timeout(timeout=10)
@pytest.mark.timeout(timeout=60)
@patch("aignostics.application._cli.SystemService.health_static")
def test_cli_run_submit_succeeds_when_system_degraded_and_no_force(
mock_health: MagicMock, runner: CliRunner, tmp_path: Path
Expand Down
48 changes: 38 additions & 10 deletions tests/aignostics/system/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,53 @@
THE_VALUE = "test_secret_value_not_real_for_testing_only"


@pytest.mark.e2e
@pytest.mark.scheduled
@pytest.mark.timeout(timeout=60)
def test_cli_health_json(runner: CliRunner, record_property) -> None:
"""Check health is true."""
@pytest.mark.unit
@patch("aignostics.system._cli._service")
def test_cli_health_json_format(mock_service: MagicMock, runner: CliRunner, record_property) -> None:
"""Check health CLI renders UP status correctly as JSON."""
record_property("tested-item-id", "TEST-SYSTEM-CLI-HEALTH-JSON")
from aignostics.utils import Health

mock_service.health.return_value = Health(status=Health.Code.UP)
result = runner.invoke(cli, ["system", "health"])
assert result.exit_code == 0
assert normalize_output(result.stdout).startswith('{ "status": "UP"')


@pytest.mark.unit
@patch("aignostics.system._cli._service")
def test_cli_health_yaml_format(mock_service: MagicMock, runner: CliRunner, record_property) -> None:
"""Check health CLI renders UP status correctly as YAML."""
record_property("tested-item-id", "TEST-SYSTEM-CLI-HEALTH-YAML")
from aignostics.utils import Health

mock_service.health.return_value = Health(status=Health.Code.UP)
result = runner.invoke(cli, ["system", "health", "--output-format", "yaml"])
assert result.exit_code == 0
assert "status: UP" in result.stdout


@pytest.mark.e2e
@pytest.mark.scheduled
@pytest.mark.timeout(timeout=60)
def test_cli_health_json(runner: CliRunner) -> None:
"""Check health CLI returns valid JSON with a valid status value."""
import json

result = runner.invoke(cli, ["system", "health"])
data = json.loads(result.stdout)
assert data["status"] in {"UP", "DEGRADED", "DOWN"}


@pytest.mark.e2e
@pytest.mark.timeout(timeout=30)
def test_cli_health_yaml(runner: CliRunner, record_property) -> None:
"""Check health is true."""
record_property("tested-item-id", "TEST-SYSTEM-CLI-HEALTH-YAML")
def test_cli_health_yaml(runner: CliRunner) -> None:
"""Check health CLI returns valid YAML with a valid status value."""
import yaml

result = runner.invoke(cli, ["system", "health", "--output-format", "yaml"])
assert "status: UP" in result.stdout
assert result.exit_code == 0
data = yaml.safe_load(result.stdout)
assert data["status"] in {"UP", "DEGRADED", "DOWN"}


@pytest.mark.e2e
Expand Down
Loading