From 8c0d2712445f2f175fbfddfde29a783af6530af9 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 3 Jul 2026 18:01:03 +0200 Subject: test(budget): assert each command binds to its handler Co-Authored-By: Claude Opus 4.8 --- tests/unit/test_commands_budget.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/unit/test_commands_budget.py b/tests/unit/test_commands_budget.py index 15e89c4..b365d27 100644 --- a/tests/unit/test_commands_budget.py +++ b/tests/unit/test_commands_budget.py @@ -158,5 +158,27 @@ class TestBudgetLimit(unittest.TestCase): self.assertEqual(body["currency_code"], "EUR") +class TestBudgetRegistration(unittest.TestCase): + # Guards the v0.3.7 class of bug: unit tests call cmd_* directly and bypass + # the registry, so a decorator bound to the wrong function is invisible to + # them. Assert each budget command is registered AND bound to its handler. + def test_each_budget_command_binds_to_its_handler(self): + from firefly_cli import registry + import firefly_cli.commands # noqa: F401 ensure all modules registered + expected = { + "budget list": budget.cmd_list, + "budget create": budget.cmd_create, + "budget delete": budget.cmd_delete, + "budget enable": budget.cmd_enable, + "budget disable": budget.cmd_disable, + "budget limit-list": budget.cmd_limit_list, + "budget limit-set": budget.cmd_limit_set, + } + by_name = {c.name: c.handler for c in registry.all_commands()} + for name, fn in expected.items(): + self.assertIn(name, by_name, f"{name} not registered") + self.assertIs(by_name[name], fn, f"{name} bound to wrong handler") + + if __name__ == "__main__": unittest.main() -- cgit v1.2.3