From c7e402dd0276042fb0cdb725d93e570bfdc39697 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 19 Mar 2026 14:34:05 +0000 Subject: [PATCH 1/2] 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 ------------------------------- From 3196e45948fd0fa3843d95fdbd8042a204894fb8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 19 Mar 2026 16:23:26 +0000 Subject: [PATCH 2/2] fix: address review comments Remove 4 duplicate group-level --path propagation tests that replicated coverage from existing tests. Strengthen the existing live test with an output assertion to verify the session data is actually read. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/copilot_usage/test_cli.py | 36 +-------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/tests/copilot_usage/test_cli.py b/tests/copilot_usage/test_cli.py index d80ee7b..604a935 100644 --- a/tests/copilot_usage/test_cli.py +++ b/tests/copilot_usage/test_cli.py @@ -746,41 +746,7 @@ def test_group_path_propagates_to_live(tmp_path: Path) -> None: runner = CliRunner() result = runner.invoke(main, ["--path", str(tmp_path), "live"]) 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 + assert "grp_liv00" in result.output or "GrpLive" in result.output # 5. Auto-refresh branches in _interactive_loop -------------------------------