aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/conftest.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-24 18:19:13 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-24 18:19:13 +0200
commit6e9afe3e54ab6fb0162393150b7892655b4561d4 (patch)
treef1cf20d891bf0d75dd206953bcec781f47ab7b15 /packages/meshbay-node/tests/conftest.py
parenta408a25af7b91abf729ec5fac7e5506437a86049 (diff)
downloadmeshbay-6e9afe3e54ab6fb0162393150b7892655b4561d4.tar.gz
refactor(node): move the CLI out of daemon.py into cli/
Each `if args.command == ...` branch of main() becomes a function in cli/ (one module per family of verbs); the parser, the process setup and a VERBS table go to cli/parser.py and cli/dispatch.py. daemon.main runs the verb or starts the daemon. Tests patch the CLI through conftest.patch_cli; the CLI golden is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests/conftest.py')
-rw-r--r--packages/meshbay-node/tests/conftest.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/conftest.py b/packages/meshbay-node/tests/conftest.py
index 2ca0c8a..9ef23a3 100644
--- a/packages/meshbay-node/tests/conftest.py
+++ b/packages/meshbay-node/tests/conftest.py
@@ -92,3 +92,26 @@ def opened_ack(session, msg: dict) -> dict:
ctx = session._group_ctx()
return file_upload_ack_payload(ctx["gek"], session._group_id or "", msg)
+
+
+def patch_cli(monkeypatch, name: str, value) -> None:
+ """Replace `name` wherever `meshbay-node`'s command line reads it.
+
+ Each module of `meshbay_node.cli` imports what it uses by name, so a helper
+ like `_daemon_api` is bound once in every module that calls it, and patching
+ the one that defines it leaves the verbs calling the real thing — which
+ talks to whatever node is running on this machine. `daemon` is included:
+ its `main()` still reads the config path when no verb is given.
+ """
+ import importlib
+ import pkgutil
+
+ import meshbay_node.cli as cli
+ from meshbay_node import daemon
+
+ modules = [daemon] + [importlib.import_module(f"meshbay_node.cli.{m.name}")
+ for m in pkgutil.iter_modules(cli.__path__)]
+ holders = [m for m in modules if hasattr(m, name)]
+ assert holders, f"no module of the CLI has {name!r} to patch"
+ for module in holders:
+ monkeypatch.setattr(module, name, value)