Files
hermes-agent/tests/pm/test_plugin_inputs.py
ethernet 9b4ed5f5ec refactor(pm): one plugin-input request for sync_venv and venv_is_current
sync_venv took four mutually exclusive plugin kwargs (plugin_dirs,
extra_plugin_dirs, selection, staged_plugin) and venv_is_current two, with
runtime ValueErrors guarding the combinations. Replace them with a single
`plugins=` argument typed as one of pm.plugin_inputs.Members, Candidates,
Selection or StagedUpdate, so a conflicting request cannot be expressed.
The module also owns the worker wire encoding that client.py and worker.py
each duplicated.

pm.install.sync_venv is split into cohesive helpers (feature policy,
install lock, publication snapshot, target selection, commit) with the
same ordering, receipts and recovery; its CC drops from 54 to 16.

All in-tree callers and tests move to the new argument.
2026-09-24 14:08:21 -04:00

26 lines
1.1 KiB
Python

"""The worker receives the same plugin input the caller built."""
from __future__ import annotations
import json
import pytest
from pm.plugin_inputs import Candidates, Members, Selection, StagedUpdate, decode, encode
@pytest.mark.parametrize("build", [
lambda root: None,
lambda root: Members([]),
lambda root: Members([root / "plugins/a", root / "plugins/b"]),
lambda root: Members({root / "home/plugins/a": root / "staged/a"}),
lambda root: Candidates([root / "plugins/candidate"]),
lambda root: Selection({"home": str(root / "home"), "enabled": ["a"], "disabled": [],
"expected_config": "missing"}),
lambda root: StagedUpdate({"target": str(root / "home/plugins/a"), "staged": str(root / "staged/a"),
"target_digest": None, "old_metadata": {},
"new_metadata": {"a": {"revision": "new"}}}),
])
def test_plugin_input_survives_the_worker_wire(build, tmp_path):
plugins = build(tmp_path)
assert decode(json.loads(json.dumps(encode(plugins)))) == plugins