From fcb33343bb5abd27cd8028fbe60811fff4791202 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 15 Mar 2026 21:01:24 +0000 Subject: [PATCH] test: add group-level --path propagation tests for all subcommands (#60) Add four tests verifying that --path passed at the group level (before the subcommand name) propagates correctly to summary, cost, live, and session subcommands via ctx.obj. These tests use the exact session IDs and assertions specified in issue #60. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/copilot_usage/test_cli.py | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/copilot_usage/test_cli.py b/tests/copilot_usage/test_cli.py index 7227ee3..d80ee7b 100644 --- a/tests/copilot_usage/test_cli.py +++ b/tests/copilot_usage/test_cli.py @@ -748,6 +748,41 @@ def test_group_path_propagates_to_live(tmp_path: Path) -> None: assert result.exit_code == 0 +def test_summary_group_path_propagation(tmp_path: Path) -> None: + """summary reads --path from group level when not provided at subcommand level.""" + _write_session(tmp_path, "grp10000-0000-0000-0000-000000000000", name="GroupPath") + runner = CliRunner() + # --path before subcommand name → stored in ctx.obj, not subcommand + result = runner.invoke(main, ["--path", str(tmp_path), "summary"]) + assert result.exit_code == 0 + assert "GroupPath" in result.output + + +def test_cost_group_path_propagation(tmp_path: Path) -> None: + _write_session(tmp_path, "grp20000-0000-0000-0000-000000000000", name="CostGroup") + runner = CliRunner() + result = runner.invoke(main, ["--path", str(tmp_path), "cost"]) + assert result.exit_code == 0 + + +def test_live_group_path_propagation(tmp_path: Path) -> None: + _write_session( + tmp_path, "grp30000-0000-0000-0000-000000000000", name="LiveGroup", active=True + ) + runner = CliRunner() + result = runner.invoke(main, ["--path", str(tmp_path), "live"]) + assert result.exit_code == 0 + + +def test_session_group_path_propagation(tmp_path: Path) -> None: + sid = "grp40000-0000-0000-0000-000000000000" + _write_session(tmp_path, sid, name="SessGroup") + runner = CliRunner() + # session needs the session_id positional argument + result = runner.invoke(main, ["--path", str(tmp_path), "session", sid[:8]]) + assert result.exit_code == 0 + + # 5. Auto-refresh branches in _interactive_loop -------------------------------