From b3d672549dba640c2f4ee978f432857d2ce7ccdf Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 30 Jun 2026 15:40:40 +0200 Subject: test: cover --human _VIEWS; add TODO.md Add unit tests for each output view (account, tag, account balance, category): right columns surfaced, API plumbing dropped. Add TODO.md listing the deferred command groups and follow-up work. Co-Authored-By: Claude Opus 4.8 --- tests/unit/test_output.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/unit/test_output.py') diff --git a/tests/unit/test_output.py b/tests/unit/test_output.py index 5b154d9..2e3e5ea 100644 --- a/tests/unit/test_output.py +++ b/tests/unit/test_output.py @@ -75,3 +75,41 @@ class TestOutput(unittest.TestCase): tty = TTY() emit([tx], human=True, stream=tty) self.assertIn("\033[31m", tty.getvalue()) # tty: withdrawal is red + + def _emit(self, row): + buf = io.StringIO() + emit([row], human=True, stream=buf) + return buf.getvalue() + + def test_view_account_shows_balance_drops_plumbing(self): + # account_role signature -> the account view. + out = self._emit({"id": "6", "name": "BBVA", "type": "asset", + "account_role": "defaultAsset", + "current_balance": "1590.92", "currency_code": "EUR", + "active": True, "iban": "IT68...", "notes": "secret"}) + self.assertIn("BBVA", out) + self.assertIn("1590.92", out) + self.assertIn("currency_code", out) + self.assertNotIn("iban", out) # plumbing column dropped + self.assertNotIn("secret", out) + + def test_view_tag(self): + out = self._emit({"id": "9", "tag": "2026", "description": "yr", + "zoom_level": None, "latitude": None}) + self.assertIn("2026", out) + self.assertIn("description", out) + self.assertNotIn("zoom_level", out) + + def test_view_account_balance(self): + # The balance handler emits id+name+current_balance (no account_role). + out = self._emit({"id": "6", "name": "BBVA", + "current_balance": "1590.92"}) + self.assertIn("current_balance", out) + self.assertIn("1590.92", out) + + def test_view_category_name_only(self): + out = self._emit({"id": "2", "name": "Food", "spent": [], + "primary_currency_code": "EUR", "notes": "junk"}) + self.assertIn("Food", out) + self.assertNotIn("primary_currency_code", out) + self.assertNotIn("spent", out) -- cgit v1.2.3