aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_commands_budget.py22
1 files changed, 22 insertions, 0 deletions
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()