fix(tests): mock get_hermes_home with Path, not str, across tui_gateway tests
tests/tui_gateway/test_slash_worker_profile_home.py broke main CI after56a41715dcadded `from hermes_state import _BARE_BILLING_PROVIDERS` to tui_gateway/server.py: importing hermes_state evaluates `DEFAULT_DB_PATH = get_hermes_home() / "state.db"` at module level, and the test's sys.modules mock returned a plain str -> TypeError: unsupported operand type(s) for /: 'str' and 'str'. The real get_hermes_home() returns a Path; a str-returning mock is a latent landmine in every test that stubs hermes_constants this way. Fix the class: all 8 tui_gateway test files now mock it with Path("/tmp/..."). Validation: the failing test reproduced at origin/main tip (56a41715dc) in a clean worktree; with this change all 82 tests across the touched files pass.
This commit is contained in:
parent
56a41715dc
commit
4f37f0e837
|
|
@ -7,6 +7,7 @@ silently reset mid-turn.
|
|||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
import importlib
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ def server():
|
|||
"sys.modules",
|
||||
{
|
||||
"hermes_constants": MagicMock(
|
||||
get_hermes_home=MagicMock(return_value="/tmp/hermes_test_compaction")
|
||||
get_hermes_home=MagicMock(return_value=Path("/tmp/hermes_test_compaction"))
|
||||
),
|
||||
"hermes_cli.env_loader": MagicMock(),
|
||||
"hermes_cli.banner": MagicMock(),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import sys
|
|||
import threading
|
||||
import time
|
||||
from unittest.mock import MagicMock, patch
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ def server():
|
|||
# the whole test would poison modules first imported inside test bodies
|
||||
# (see tests/tui_gateway/test_protocol.py for the full rationale).
|
||||
with patch.dict("sys.modules", {
|
||||
"hermes_constants": MagicMock(get_hermes_home=MagicMock(return_value="/tmp/hermes_test")),
|
||||
"hermes_constants": MagicMock(get_hermes_home=MagicMock(return_value=Path("/tmp/hermes_test"))),
|
||||
"hermes_cli.env_loader": MagicMock(),
|
||||
"hermes_cli.banner": MagicMock(),
|
||||
"hermes_state": MagicMock(),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ thinking block tagged with its source model.
|
|||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ def server():
|
|||
"sys.modules",
|
||||
{
|
||||
"hermes_constants": MagicMock(
|
||||
get_hermes_home=MagicMock(return_value="/tmp/hermes_test_moa_emit")
|
||||
get_hermes_home=MagicMock(return_value=Path("/tmp/hermes_test_moa_emit"))
|
||||
),
|
||||
"hermes_cli.env_loader": MagicMock(),
|
||||
"hermes_cli.banner": MagicMock(),
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import threading
|
|||
import time
|
||||
import types
|
||||
from unittest.mock import MagicMock, patch
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ def server():
|
|||
# (a fixed shared path) forever, leaking active-session registry entries
|
||||
# across every later test in the process. Scope the patch to the import.
|
||||
with patch.dict("sys.modules", {
|
||||
"hermes_constants": MagicMock(get_hermes_home=MagicMock(return_value="/tmp/hermes_test")),
|
||||
"hermes_constants": MagicMock(get_hermes_home=MagicMock(return_value=Path("/tmp/hermes_test"))),
|
||||
"hermes_cli.env_loader": MagicMock(),
|
||||
"hermes_cli.banner": MagicMock(),
|
||||
"hermes_state": MagicMock(),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ transcript line.
|
|||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
|
@ -24,7 +25,7 @@ def server():
|
|||
"sys.modules",
|
||||
{
|
||||
"hermes_constants": MagicMock(
|
||||
get_hermes_home=MagicMock(return_value="/tmp/hermes_test_review_summary")
|
||||
get_hermes_home=MagicMock(return_value=Path("/tmp/hermes_test_review_summary"))
|
||||
),
|
||||
"hermes_cli.env_loader": MagicMock(),
|
||||
"hermes_cli.banner": MagicMock(),
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import os
|
|||
import subprocess
|
||||
import sys
|
||||
from unittest.mock import MagicMock, patch, call
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ import pytest
|
|||
def test_slash_worker_accepts_profile_home():
|
||||
"""_SlashWorker.__init__ accepts profile_home parameter."""
|
||||
with patch.dict("sys.modules", {
|
||||
"hermes_constants": MagicMock(get_hermes_home=MagicMock(return_value="/tmp/hermes_test")),
|
||||
"hermes_constants": MagicMock(get_hermes_home=MagicMock(return_value=Path("/tmp/hermes_test"))),
|
||||
}):
|
||||
with patch("subprocess.Popen") as mock_popen:
|
||||
mock_popen.return_value.stdout = MagicMock()
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ shows a real midstream turn instead of sitting silent until persistence.
|
|||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ def server():
|
|||
"sys.modules",
|
||||
{
|
||||
"hermes_constants": MagicMock(
|
||||
get_hermes_home=MagicMock(return_value="/tmp/hermes_test_child_mirror")
|
||||
get_hermes_home=MagicMock(return_value=Path("/tmp/hermes_test_child_mirror"))
|
||||
),
|
||||
"hermes_cli.env_loader": MagicMock(),
|
||||
"hermes_cli.banner": MagicMock(),
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ the crash class cannot silently regress.
|
|||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
import subprocess
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
|
@ -42,7 +43,7 @@ def test_slash_worker_popen_uses_utf8_replace():
|
|||
"""
|
||||
with patch.dict("sys.modules", {
|
||||
"hermes_constants": MagicMock(
|
||||
get_hermes_home=MagicMock(return_value="/tmp/hermes_test")
|
||||
get_hermes_home=MagicMock(return_value=Path("/tmp/hermes_test"))
|
||||
),
|
||||
}):
|
||||
with patch("subprocess.Popen") as mock_popen:
|
||||
|
|
|
|||
Loading…
Reference in New Issue