From 0c9939c5961a3cef50e6378c0eefbeaae00f4c67 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 1 Jul 2026 10:18:39 +0200 Subject: feat: tx list --all + truncation signal (v0.3.1) tx list silently returned only --limit rows (default 20) with no signal when more matched, making a correct ledger look wrong during reconciliation. - --all auto-paginates every page via meta.pagination.total_pages - without --all, print "showing N of M (use --all for all)" to stderr when the result is truncated (stdout JSON stays clean) PATCH: new optional flag + stderr note, contract unchanged. Co-Authored-By: Claude Opus 4.8 --- tests/unit/test_commands_transaction.py | 48 ++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'tests/unit') diff --git a/tests/unit/test_commands_transaction.py b/tests/unit/test_commands_transaction.py index 325dcb7..d8b81da 100644 --- a/tests/unit/test_commands_transaction.py +++ b/tests/unit/test_commands_transaction.py @@ -139,9 +139,55 @@ class TestTxList(unittest.TestCase): ctx, client, _ = make_ctx() client.request.return_value = {"data": []} args = MagicMock(since="2026-06-01", until="2026-06-30", - account=None, limit=10) + account=None, limit=10, all=False) tx.cmd_list(args, ctx) params = client.request.call_args[1]["params"] self.assertEqual(params["start"], "2026-06-01") self.assertEqual(params["end"], "2026-06-30") self.assertEqual(params["limit"], 10) + + def test_list_warns_when_truncated(self): + import io + from contextlib import redirect_stderr + ctx, client, _ = make_ctx() + client.request.return_value = { + "data": [{"id": str(i)} for i in range(20)], + "meta": {"pagination": {"total": 90, "count": 20, + "current_page": 1, "total_pages": 5}}, + } + args = MagicMock(since=None, until=None, account=None, limit=20, all=False) + buf = io.StringIO() + with redirect_stderr(buf): + tx.cmd_list(args, ctx) + self.assertIn("showing 20 of 90", buf.getvalue()) + self.assertEqual(client.request.call_count, 1) + + def test_list_no_warn_when_complete(self): + import io + from contextlib import redirect_stderr + ctx, client, _ = make_ctx() + client.request.return_value = { + "data": [{"id": "1"}], + "meta": {"pagination": {"total": 1, "count": 1, + "current_page": 1, "total_pages": 1}}, + } + args = MagicMock(since=None, until=None, account=None, limit=20, all=False) + buf = io.StringIO() + with redirect_stderr(buf): + tx.cmd_list(args, ctx) + self.assertEqual(buf.getvalue(), "") + + def test_list_all_paginates(self): + ctx, client, _ = make_ctx() + def page(method, path, params=None, body=None): + p = params["page"] + return { + "data": [{"id": f"{p}-{i}"} for i in range(2)], + "meta": {"pagination": {"total": 4, "count": 2, + "current_page": p, "total_pages": 2}}, + } + client.request.side_effect = page + args = MagicMock(since=None, until=None, account=None, limit=2, all=True) + rc = tx.cmd_list(args, ctx) + self.assertEqual(rc, 0) + self.assertEqual(client.request.call_count, 2) -- cgit v1.2.3