fix: sync Python Auggie matcher validation
This commit is contained in:
1 parent
e334e84333
commit
51921e9101
5 files changed
+127
-8
No files matched your search
@@ -0,0 +1,51 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from typing import NoReturn
|
||||
|
||||
import pytest
|
||||
|
||||
from elydora.plugins import augment
|
||||
|
||||
|
||||
MATCHER_HOOKS = {
|
||||
"PreToolUse": [
|
||||
{
|
||||
"matcher": "(?<tool>launch-process)",
|
||||
"hooks": [],
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_matcher_validation_requires_node(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
monkeypatch.setattr(augment.shutil, "which", lambda _: None)
|
||||
|
||||
with pytest.raises(FileNotFoundError, match="Node.js runtime is required"):
|
||||
augment._validate_matchers(MATCHER_HOOKS)
|
||||
|
||||
|
||||
def test_matcher_validation_skips_node_without_matchers(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
def fail_lookup(_: str) -> NoReturn:
|
||||
raise AssertionError("Node.js lookup must be skipped")
|
||||
|
||||
monkeypatch.setattr(augment.shutil, "which", fail_lookup)
|
||||
|
||||
augment._validate_matchers({"SessionStart": [{"hooks": []}]})
|
||||
|
||||
|
||||
def test_matcher_validation_surfaces_timeout(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
def time_out(*args: object, **kwargs: object) -> NoReturn:
|
||||
raise subprocess.TimeoutExpired(cmd="node", timeout=10)
|
||||
|
||||
monkeypatch.setattr(augment.shutil, "which", lambda _: "node")
|
||||
monkeypatch.setattr(augment.subprocess, "run", time_out)
|
||||
|
||||
with pytest.raises(TimeoutError, match="timed out after 10 seconds"):
|
||||
augment._validate_matchers(MATCHER_HOOKS)
|
||||
@@ -159,7 +159,7 @@ def test_install_preserves_user_settings_and_is_idempotent(
|
||||
],
|
||||
"PreToolUse": [
|
||||
{
|
||||
"matcher": "launch-process",
|
||||
"matcher": "(?<tool>launch-process)",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
|
||||
Reference in new issue
Block a user