Files
hermes-agent/tests/workspace/conftest.py
T
alt-glitch ec18a783d8 refactor(workspace): tighten types + dedupe after /simplify pass
- Narrow markdown pipeline result with isinstance assert (static type
  correctness; .code/.tables/.images access no longer leaks Document
  abstraction).
- Simplify _execute_with_lock_retry to 5 linear-backoff attempts; the
  helper was tuned for WAL schema bootstrap, not repeated retry.
- Add Literal['markdown','code','plain'] alias for pipeline keys so
  typos at the dispatch site become type errors.
- Fix misleading stage="discover" label on post-discovery errors;
  relabel as "read" where it actually applies.
- Extract _make_config / _write into tests/workspace/conftest.py
  fixtures so the two test files share one source.
- Factor str(Path(raw).resolve()) into workspace.constants.resolve_path_prefix
  and call from both search_workspace and the CLI command.
- Drop a stale WHAT-comment on the retry backoff line.
2026-04-18 08:17:39 +05:30

32 lines
926 B
Python

from __future__ import annotations
from pathlib import Path
import pytest
from workspace.config import WorkspaceConfig
from workspace.constants import DEFAULT_IGNORE_PATTERNS
@pytest.fixture
def make_workspace_config(tmp_path: Path):
def _make(raw: dict | None = None) -> WorkspaceConfig:
hermes_home = tmp_path / "cfg_home"
hermes_home.mkdir(exist_ok=True)
cfg = WorkspaceConfig.from_dict(raw or {}, hermes_home)
cfg.workspace_root.mkdir(parents=True, exist_ok=True)
(cfg.workspace_root / ".hermesignore").write_text(
DEFAULT_IGNORE_PATTERNS + "\n.hermesignore\n",
encoding="utf-8",
)
return cfg
return _make
@pytest.fixture
def write_file():
def _write(path: Path, text: str) -> Path:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(text, encoding="utf-8")
return path
return _write