from pathlib import Path import sys import subprocess # Ensure `installer` is importable when tests are invoked directly via `pytest` # (the project also provides `tests/run_tests.sh` which sets `PYTHONPATH=.`). PROJECT_ROOT = Path(__file__).resolve().parents[2] if str(PROJECT_ROOT) not in sys.path: sys.path.insert(0, str(PROJECT_ROOT)) from knoe.core import env as core_env def test_verify_k3s_services_status_does_not_require_token_when_kubeconfig_available( monkeypatch, tmp_path ): kubeconfig = tmp_path / "kubeconfig" kubeconfig.write_text("dummy") def fake_run(cmd, capture_output=True, text=True, timeout=None, env=None): return subprocess.CompletedProcess( args=cmd, returncode=0, stdout="registry\nopenbao\nopentofu\n", stderr="", ) monkeypatch.setattr(core_env.subprocess, "run", fake_run) status = core_env._verify_k3s_services_status( project_root=PROJECT_ROOT, managed_kubeconfig=str(kubeconfig), ) assert status["registry"] == "Good" assert status["openbao"] == "Good" assert status["opentofu"] == "Good"