From 544e3d167d25597227e09f791698f5e0092051fb Mon Sep 17 00:00:00 2001 From: Samsie Date: Sun, 14 Jun 2026 13:51:26 +0530 Subject: [PATCH] test: add integration tests for CLI status command JSON output --- tests/test_cli_status.py | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/test_cli_status.py diff --git a/tests/test_cli_status.py b/tests/test_cli_status.py new file mode 100644 index 0000000..7893f80 --- /dev/null +++ b/tests/test_cli_status.py @@ -0,0 +1,50 @@ +import json +import subprocess +import sys +import tempfile +import unittest +from pathlib import Path + +from hermes_collab_engine.store import CollabStore + + +REPO_ROOT = Path(__file__).resolve().parents[1] + + +def run_cli(*args: str) -> subprocess.CompletedProcess: + return subprocess.run( + [sys.executable, "-m", "hermes_collab_engine.cli", *args], + capture_output=True, + text=True, + check=False, + cwd=str(REPO_ROOT), + ) + + +class StatusCliTests(unittest.TestCase): + def test_status_json_returns_expected_structure(self): + with tempfile.TemporaryDirectory() as tmp: + db_path = Path(tmp) / "db.sqlite3" + # Initialize an empty store to avoid using real runtime databases + CollabStore(db_path) + + proc = run_cli("status", "--db", str(db_path), "--json") + + self.assertEqual(proc.returncode, 0, msg=f"stdout={proc.stdout!r} stderr={proc.stderr!r}") + + try: + result = json.loads(proc.stdout) + except json.JSONDecodeError: + self.fail(f"CLI output is not valid JSON: {proc.stdout}") + + self.assertIn("overview", result) + self.assertIn("runs", result) + self.assertIn("lessons", result) + + self.assertIsInstance(result["overview"], dict) + self.assertIsInstance(result["runs"], list) + self.assertIsInstance(result["lessons"], list) + + +if __name__ == "__main__": + unittest.main()