summaryrefslogtreecommitdiff
path: root/tests/hermes/conftest.py
blob: ec22bed5bb3b1386a8bd01ba170d21bceb23cef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pathlib import Path

import pytest
from unittest.mock import MagicMock


@pytest.fixture
def mock_ctx():
    ctx = MagicMock()
    ctx._hooks = {}
    ctx._skills = {}
    ctx._descriptions = {}

    def register_hook(event, fn):
        ctx._hooks[event] = fn

    def register_skill(name, path, description="", frontmatter=None):
        # Mimic hermes' real register_skill, which calls path.exists() and
        # therefore breaks on a str (the bug that silently disabled the whole
        # plugin, found 2026-07-23). Keeping that fidelity here means a
        # regression to str paths fails these tests instead of failing
        # silently inside hermes.
        if not isinstance(path, Path):
            raise AttributeError(
                f"register_skill requires a pathlib.Path, got {type(path).__name__}"
            )
        ctx._skills[name] = path
        ctx._descriptions[name] = description

    ctx.register_hook.side_effect = register_hook
    ctx.register_skill.side_effect = register_skill
    return ctx