claude-video/tests/test_hook.py
bradautomates e90ef44c32 Implement v0.3.0 reliability fixes and managed WhisperX transcription
Add opt-in local transcription with managed installation, cache warm-up,
and a one-time backend choice while preserving native-caption priority.

Correct frame timing and coverage, caption provenance and download
ownership, configuration parsing, provider pairing, and partial reports.
Update cross-host instructions, packaging, and test-gated release CI.

Validate 198 isolated tests, real local English and Spanish inference,
network-denied warm-cache inference, live captions/media, and packaging.
Record platform and account-dependent acceptance limits separately.
2026-09-12 22:09:43 +10:00

38 lines
1.5 KiB
Python

"""The Claude hook is advisory even when its interpreter/config cannot be used."""
import os
import shutil
import subprocess
from pathlib import Path
import pytest
HOOK = Path(__file__).resolve().parents[1] / 'hooks/scripts/check-setup.sh'
@pytest.mark.parametrize('code', [0, 2])
def test_hook_handles_setup_failure_and_spaced_plugin_path(tmp_path, code):
bash = shutil.which('bash')
if not bash or os.name == 'nt':
pytest.skip('Bash fixture runs on POSIX; Windows runtime checks are separate')
plugin = tmp_path / 'plugin with spaces'
script = plugin / 'skills/watch/scripts/setup.py'
script.parent.mkdir(parents=True)
script.write_text(f'raise SystemExit({code})\n')
result = subprocess.run([bash, str(HOOK)], env={**os.environ, 'CLAUDE_PLUGIN_ROOT': str(plugin)}, capture_output=True, text=True)
assert result.returncode == 0
assert bool(result.stdout) == bool(code)
def test_hook_handles_broken_interpreters(tmp_path):
bash = shutil.which('bash')
if not bash or os.name == 'nt':
pytest.skip('Requires POSIX executable scripts')
bindir = tmp_path / 'bin'
bindir.mkdir()
for name in ('python', 'python3'):
path = bindir / name
path.write_text('#!/bin/sh\nexit 1\n')
path.chmod(0o755)
result = subprocess.run([bash, str(HOOK)], env={**os.environ, 'PATH': str(bindir), 'CLAUDE_PLUGIN_ROOT': str(tmp_path)}, capture_output=True, text=True)
assert result.returncode == 0 and 'Python' in result.stdout