aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-06-30 10:59:43 +0200
committerDanilo M. <danix@danix.xyz>2026-06-30 10:59:43 +0200
commitba872d1e48ad229903316fc30e61cebe9c115258 (patch)
treebb6f37e12423f56bd66ab2fa784644813a141174 /tests/unit
parent09dddee3ebbbbbb8ed6eac74370232e76e84d7bb (diff)
downloadfirefly-cli-ba872d1e48ad229903316fc30e61cebe9c115258.tar.gz
firefly-cli-ba872d1e48ad229903316fc30e61cebe9c115258.zip
feat: command registry and context
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_registry.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit/test_registry.py b/tests/unit/test_registry.py
new file mode 100644
index 0000000..f30a5df
--- /dev/null
+++ b/tests/unit/test_registry.py
@@ -0,0 +1,23 @@
+import unittest
+from firefly_cli import registry
+
+class TestRegistry(unittest.TestCase):
+ def setUp(self):
+ registry._COMMANDS.clear()
+
+ def test_command_decorator_registers(self):
+ @registry.command("tx add", help="add a tx")
+ def handler(args, ctx):
+ return 0
+ cmds = registry.all_commands()
+ self.assertEqual(len(cmds), 1)
+ self.assertEqual(cmds[0].name, "tx add")
+ self.assertIs(cmds[0].handler, handler)
+
+ def test_add_arguments_callback_stored(self):
+ def args_cb(p):
+ p.add_argument("name")
+ @registry.command("account get", args=args_cb)
+ def handler(args, ctx):
+ return 0
+ self.assertIs(registry.all_commands()[0].args, args_cb)