simplify(compat): hermes_cli small facades — drop 7 re-exports/aliases (+relay_runtime alias module), repoint 12 callers/tests
This commit is contained in:
@@ -632,16 +632,16 @@ class TestRoundTrip:
|
||||
|
||||
class TestFormatSize:
|
||||
def test_bytes(self):
|
||||
from hermes_cli.backup import _format_size
|
||||
from hermes_cli.sizefmt import format_bytes as _format_size
|
||||
assert _format_size(512) == "512 B"
|
||||
|
||||
def test_kilobytes(self):
|
||||
from hermes_cli.backup import _format_size
|
||||
from hermes_cli.sizefmt import format_bytes as _format_size
|
||||
assert "KB" in _format_size(2048)
|
||||
|
||||
|
||||
def test_terabytes(self):
|
||||
from hermes_cli.backup import _format_size
|
||||
from hermes_cli.sizefmt import format_bytes as _format_size
|
||||
assert "TB" in _format_size(2 * 1024 ** 4)
|
||||
|
||||
|
||||
|
||||
@@ -12,10 +12,8 @@ from argparse import Namespace
|
||||
|
||||
import pytest
|
||||
|
||||
from hermes_cli.cron import (
|
||||
_contains_gateway_lifecycle_command,
|
||||
cron_command,
|
||||
)
|
||||
from cron.lifecycle_guard import contains_gateway_lifecycle_command as _contains_gateway_lifecycle_command
|
||||
from hermes_cli.cron import cron_command
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Timing out a git probe must not leave helper descendants (credential helpers,
|
||||
``git-remote-https``, hook children) running after the probe returns. The
|
||||
probe spawns the child in its own process group (``process_group=0``) and
|
||||
``_kill_git_process_tree`` signals the whole group with ``os.killpg`` — but
|
||||
``kill_process_tree`` signals the whole group with ``os.killpg`` — but
|
||||
only when the child actually leads its own group, so a shared-group spawn can
|
||||
never take down unrelated processes.
|
||||
|
||||
@@ -20,7 +20,7 @@ import time
|
||||
import pytest
|
||||
|
||||
from hermes_cli import _subprocess_compat
|
||||
from hermes_cli._subprocess_compat import _kill_git_process_tree, bounded_git_probe
|
||||
from hermes_cli._subprocess_compat import bounded_git_probe, kill_process_tree
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
sys.platform == "win32", reason="POSIX process-group semantics"
|
||||
@@ -94,7 +94,7 @@ def test_posix_spawn_uses_own_process_group(tmp_path):
|
||||
|
||||
|
||||
def test_group_kill_skipped_when_child_shares_our_group():
|
||||
"""_kill_git_process_tree must never killpg a group the child doesn't lead.
|
||||
"""kill_process_tree must never killpg a group the child doesn't lead.
|
||||
|
||||
Spawn WITHOUT process_group=0 (child inherits OUR group): the ownership
|
||||
check (pgid == pid) must skip the group signal, or the test process itself
|
||||
@@ -107,7 +107,7 @@ def test_group_kill_skipped_when_child_shares_our_group():
|
||||
stdin=subprocess.DEVNULL,
|
||||
)
|
||||
assert os.getpgid(proc.pid) == os.getpgid(0) # shared group precondition
|
||||
_kill_git_process_tree(proc)
|
||||
kill_process_tree(proc)
|
||||
proc.wait(timeout=5)
|
||||
# We are alive to make this assertion — killpg on our own group would have
|
||||
# taken the test runner down. The direct child is still killed.
|
||||
@@ -132,4 +132,4 @@ def test_kill_helper_swallow_all_failures():
|
||||
def kill(self):
|
||||
raise OSError("already reaped")
|
||||
|
||||
_kill_git_process_tree(_Dead()) # must not raise
|
||||
kill_process_tree(_Dead()) # must not raise
|
||||
|
||||
@@ -144,7 +144,9 @@ def test_tree_dirtied_between_check_and_removal_preserved(
|
||||
(wt / "late-wip.txt").write_text("dirtied after the check\n", encoding="utf-8")
|
||||
# Pre-check lies (as if the file appeared just after it ran) — real git
|
||||
# must still refuse the removal.
|
||||
monkeypatch.setattr(cli, "_worktree_is_dirty", lambda _p: False)
|
||||
from hermes_cli import worktree_ops
|
||||
|
||||
monkeypatch.setattr(worktree_ops, "_worktree_is_dirty", lambda _p: False)
|
||||
kb._cleanup_worktree_workspace("t_gggg7777", str(wt))
|
||||
assert wt.is_dir()
|
||||
assert (wt / "late-wip.txt").exists()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import importlib.metadata
|
||||
import argparse
|
||||
import json
|
||||
from types import SimpleNamespace
|
||||
@@ -75,7 +76,7 @@ def test_discover_all_plugins_includes_entrypoint_plugins(monkeypatch, tmp_path)
|
||||
lambda: bundled_dir,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
plugins_cmd.importlib.metadata,
|
||||
importlib.metadata,
|
||||
"entry_points",
|
||||
lambda: [entry_point],
|
||||
)
|
||||
@@ -117,7 +118,7 @@ def test_declared_capabilities_for_entrypoint_uses_distribution_metadata(
|
||||
"hermes_cli.plugins.get_bundled_plugins_dir", lambda: bundled_dir
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
plugins_cmd.importlib.metadata,
|
||||
importlib.metadata,
|
||||
"entry_points",
|
||||
lambda: [plugin_ep, capability_ep],
|
||||
)
|
||||
|
||||
@@ -15,7 +15,8 @@ from typing import Any
|
||||
import pytest
|
||||
|
||||
from hermes_cli import lifecycle, plugins
|
||||
from hermes_cli.observability import relay_runtime, relay_shared_metrics
|
||||
from agent import relay_runtime
|
||||
from hermes_cli.observability import relay_shared_metrics
|
||||
from hermes_cli.plugins import PluginManager
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user