mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
test(gateway): patch hermes_constants.get_hermes_home so profile store scopes to the mocked home
This commit is contained in:
parent
4cbd46545e
commit
75657f89c4
1 changed files with 10 additions and 2 deletions
|
|
@ -58,11 +58,19 @@ class TestProfileScopedDiscovery:
|
|||
global_dir = tmp_path / "global-pairing"
|
||||
global_dir.mkdir(parents=True)
|
||||
|
||||
# PairingStore.__init__ resolves the profile dir via a *function-local*
|
||||
# ``from hermes_constants import get_hermes_home``, so the patch must
|
||||
# target ``hermes_constants.get_hermes_home`` (the source module) — not
|
||||
# ``gateway.pairing.get_hermes_home`` (the module-global binding, which
|
||||
# the local re-import bypasses). Patching the wrong target would leave
|
||||
# ``self._dir`` rooted at the real HERMES_HOME.
|
||||
with patch("gateway.pairing.PAIRING_DIR", global_dir), patch(
|
||||
"gateway.pairing.get_hermes_home", return_value=home
|
||||
"hermes_constants.get_hermes_home", return_value=home
|
||||
):
|
||||
store = PairingStore(profile="alice")
|
||||
# Store lives under the profile dir, provably distinct from PAIRING_DIR.
|
||||
# Store lives under the mocked home's profile dir — provably scoped
|
||||
# there, and distinct from the module-global PAIRING_DIR.
|
||||
assert store._dir == home / "profiles" / "alice" / "pairing"
|
||||
assert store._dir != global_dir
|
||||
with store._lock:
|
||||
store._approve_user("telegram", "tg-456", "Bob")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue