29 lines
905 B
Python
29 lines
905 B
Python
from __future__ import annotations
|
|
|
|
from test_hermes_register_tools import FakeHermesContext, load_plugin_module
|
|
|
|
|
|
def test_register_registers_expected_hooks():
|
|
module = load_plugin_module()
|
|
ctx = FakeHermesContext()
|
|
|
|
module.register(ctx)
|
|
|
|
assert [item[0] for item in ctx.registered_hooks] == [
|
|
"on_session_start",
|
|
"pre_llm_call",
|
|
"post_llm_call",
|
|
"on_session_end",
|
|
]
|
|
assert all(callable(item[1]) for item in ctx.registered_hooks)
|
|
|
|
|
|
def test_hook_callbacks_accept_kwargs():
|
|
module = load_plugin_module()
|
|
|
|
assert isinstance(module.on_session_start(session_id="s", extra="x"), dict)
|
|
assert isinstance(module.pre_llm_call(user_message="", session_id="s", extra="x"), dict)
|
|
assert module.post_llm_call(user_message="hi", assistant_response="hello", extra="x") is None
|
|
assert module.on_session_end(session_id="s", extra="x") is None
|
|
|