The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): trim plugin-injector salvage to two invariants (#125102, salvage #125114)
teknium1e785ced2976b
diff --git a/tests/gateway/test_plugin_message_injection.py b/tests/gateway/test_plugin_message_injection.pyindex 1621ba747cf..398fe0ae1ec 100644--- a/tests/gateway/test_plugin_message_injection.py+++ b/tests/gateway/test_plugin_message_injection.py@@ -433,15 +433,25 @@ def test_scheduler_rejects_submission_failure():)-def test_install_and_clear_gateway_injector_use_process_host():+def test_install_and_clear_gateway_injector_preserves_newer_owner():runner = _runner(_entry())+ manager = PluginManager()- with (- patch("hermes_cli.plugins.publish_gateway_message_host") as publish,- patch("hermes_cli.plugins.clear_published_gateway_message_host") as clear,- ):+ # The runner publishes process-wide; expose this standalone manager through the legacy slot.+ with patch("hermes_cli.plugins._plugin_manager", manager):runner._install_plugin_message_injector()+ assert manager.has_gateway_message_injector is True++ runner._clear_plugin_message_injector()+ assert manager.has_gateway_message_injector is False++ runner._install_plugin_message_injector()++ newer_owner = MagicMock()+ newer_injector = MagicMock(return_value=True)+ manager.set_gateway_message_injector(newer_owner, newer_injector)runner._clear_plugin_message_injector()- publish.assert_called_once_with(runner, runner._schedule_plugin_message_injection)- clear.assert_called_once_with(runner)+ assert manager.has_gateway_message_injector is True+ assert manager.inject_gateway_message(value="kept") is True+ newer_injector.assert_called_once_with(value="kept")diff --git a/tests/hermes_cli/test_plugin_message_injection.py b/tests/hermes_cli/test_plugin_message_injection.pyindex 0474655a91b..a444452d04e 100644--- a/tests/hermes_cli/test_plugin_message_injection.py+++ b/tests/hermes_cli/test_plugin_message_injection.py@@ -7,6 +7,7 @@ from unittest.mock import MagicMock, patchimport hermes_yaml as yamlimport hermes_cli.plugins as plugins_mod+from agent import secret_scopefrom hermes_constants import reset_hermes_home_override, set_hermes_home_overridefrom hermes_cli.plugins import PluginContext, PluginManager, PluginManifest@@ -196,6 +197,9 @@ def test_published_gateway_host_reaches_existing_and_future_profile_managers(tmp)monkeypatch.setenv("HERMES_HOME", str(homes[0]))plugins_mod._reset_plugin_managers_for_tests()+ # Multiplex gateway: launch home + secondary profiles served by one process.+ was_active = secret_scope.is_multiplex_active()+ secret_scope.set_multiplex_active(True)def manager_for(home):token = set_hermes_home_override(str(home))@@ -218,6 +222,9 @@ def test_published_gateway_host_reaches_existing_and_future_profile_managers(tmplate_manager = manager_for(homes[2])assert late_manager.has_gateway_message_injector is True+ # A -> B -> A: returning to the launch home resolves the same, still-stamped manager.+ assert manager_for(homes[0]) is launch_manager+ assert launch_manager.has_gateway_message_injector is Truetoken = set_hermes_home_override(str(homes[1]))try:@@ -244,26 +251,4 @@ def test_published_gateway_host_reaches_existing_and_future_profile_managers(tmpfinally:plugins_mod.clear_published_gateway_message_host(owner)plugins_mod._reset_plugin_managers_for_tests()---def test_published_gateway_host_clear_preserves_newer_owner(tmp_path, monkeypatch):- home = tmp_path / "hermes"- home.mkdir()- monkeypatch.setenv("HERMES_HOME", str(home))- plugins_mod._reset_plugin_managers_for_tests()- manager = plugins_mod.get_plugin_manager()- older_owner, newer_owner = object(), object()- older = MagicMock(return_value=False)- newer = MagicMock(return_value=True)- try:- plugins_mod.publish_gateway_message_host(older_owner, older)- plugins_mod.publish_gateway_message_host(newer_owner, newer)- plugins_mod.clear_published_gateway_message_host(older_owner)-- assert manager.has_gateway_message_injector is True- assert manager.inject_gateway_message(session_key="kept") is True- newer.assert_called_once_with(session_key="kept")- older.assert_not_called()- finally:- plugins_mod.clear_published_gateway_message_host(newer_owner)- plugins_mod._reset_plugin_managers_for_tests()+ secret_scope.set_multiplex_active(was_active)