Skip to content

The agent that grows with you

test(cli): trim fast-serve coverage to the parity + dispatch invariants

Teknium4afbecb429a7
diff --git a/tests/hermes_cli/test_fast_serve_launch.py b/tests/hermes_cli/test_fast_serve_launch.py
index bf76cdae119..a0f3961596e 100644
--- a/tests/hermes_cli/test_fast_serve_launch.py
+++ b/tests/hermes_cli/test_fast_serve_launch.py
@@ -12,78 +12,40 @@ def _capture(_args) -> None:
return None
-def test_standalone_serve_parser_matches_full_subcommand_parser() -> None:
+def test_lean_serve_parser_matches_full_subcommand_parser() -> None:
root = argparse.ArgumentParser()
subparsers = root.add_subparsers(dest="command")
- build_dashboard_parser(
- subparsers,
- cmd_dashboard=_capture,
- cmd_dashboard_register=_capture,
- )
+ build_dashboard_parser(subparsers, cmd_dashboard=_capture, cmd_dashboard_register=_capture)
lean = build_serve_parser(cmd_dashboard=_capture)
argv = [
- "--host",
- "127.0.0.1",
- "--port",
- "0",
- "--no-open",
- "--ssh-session-token-file",
- "token.txt",
- "--ssh-owner-nonce",
- "0123456789abcdef",
+ "--host", "127.0.0.1", "--port", "0", "--no-open",
+ "--ssh-session-token-file", "token.txt", "--ssh-owner-nonce", "0123456789abcdef",
]
assert vars(lean.parse_args(argv)) == vars(root.parse_args(["serve", *argv]))
-def test_fast_serve_launch_dispatches_canonical_arguments(monkeypatch) -> None:
+def test_fast_serve_launch_dispatches_only_unambiguous_serve(monkeypatch) -> None:
captured = []
monkeypatch.setattr(config_mod, "get_container_exec_info", lambda: None)
monkeypatch.setattr(main_mod, "cmd_dashboard", captured.append)
- monkeypatch.setattr(
- sys,
- "argv",
- [
- "hermes",
- "serve",
- "--host",
- "127.0.0.1",
- "--port",
- "0",
- "--ssh-owner-nonce",
- "0123456789abcdef",
- ],
- )
+ monkeypatch.setattr(sys, "argv", ["hermes", "serve", "--host", "127.0.0.1", "--port", "0"])
assert main_mod._try_fast_serve_launch() is True
- assert len(captured) == 1
- assert captured[0].command == "serve"
- assert captured[0].headless_backend is True
- assert captured[0].no_open is True
- assert captured[0].host == "127.0.0.1"
- assert captured[0].port == 0
- assert captured[0].ssh_owner_nonce == "0123456789abcdef"
-
-
-def test_fast_serve_launch_falls_back_for_unknown_arguments(monkeypatch) -> None:
- monkeypatch.setattr(config_mod, "get_container_exec_info", lambda: None)
- monkeypatch.setattr(sys, "argv", ["hermes", "serve", "--future-flag"])
-
- assert main_mod._try_fast_serve_launch() is False
-
-
-def test_fast_serve_launch_preserves_container_routing(monkeypatch) -> None:
- monkeypatch.setattr(config_mod, "get_container_exec_info", lambda: {"name": "managed"})
- monkeypatch.setattr(sys, "argv", ["hermes", "serve"])
-
- assert main_mod._try_fast_serve_launch() is False
-
-
-def test_fast_serve_launch_preserves_help_and_opt_out(monkeypatch) -> None:
- monkeypatch.setattr(sys, "argv", ["hermes", "serve", "--help"])
- assert main_mod._try_fast_serve_launch() is False
+ assert (captured[0].command, captured[0].headless_backend, captured[0].no_open, captured[0].port) == (
+ "serve", True, True, 0,
+ )
+ # Every ambiguous shape falls back to the full parser: unknown flags,
+ # help, the opt-out, and container routing.
+ for argv in (["serve", "--future-flag"], ["serve", "--help"], ["chat"]):
+ monkeypatch.setattr(sys, "argv", ["hermes", *argv])
+ assert main_mod._try_fast_serve_launch() is False
monkeypatch.setenv("HERMES_DISABLE_FAST_SERVE_LAUNCH", "1")
monkeypatch.setattr(sys, "argv", ["hermes", "serve"])
assert main_mod._try_fast_serve_launch() is False
+ monkeypatch.delenv("HERMES_DISABLE_FAST_SERVE_LAUNCH")
+ monkeypatch.setattr(config_mod, "get_container_exec_info", lambda: {"name": "managed"})
+ assert main_mod._try_fast_serve_launch() is False
+ assert len(captured) == 1