46 lines
1.6 KiB
Python
Executable File
46 lines
1.6 KiB
Python
Executable File
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from cognitive_agent.application.gesture_bridge import GestureCapabilityBridge
|
|
|
|
|
|
def _write_bundled_assets(repository: Path) -> Path:
|
|
config = repository / "config" / "gesture" / "default.yaml"
|
|
config.parent.mkdir(parents=True)
|
|
config.write_text(
|
|
"recognition:\n action_hold_ms: 720\n armed_idle_timeout_ms: 3100\n",
|
|
encoding="utf-8",
|
|
)
|
|
asset_root = repository / "apps" / "web-console" / "assets" / "gesture"
|
|
asset_root.mkdir(parents=True)
|
|
(asset_root / "gesture_recognizer.task").write_bytes(b"model")
|
|
return asset_root
|
|
|
|
|
|
def test_gesture_bridge_uses_bundled_assets(tmp_path: Path):
|
|
asset_root = _write_bundled_assets(tmp_path)
|
|
bridge = GestureCapabilityBridge(tmp_path, asset_root)
|
|
info = bridge.runtime_info()
|
|
|
|
assert bridge.available
|
|
assert bridge.model_path == asset_root / "gesture_recognizer.task"
|
|
assert info["asset_strategy"] == "bundled"
|
|
assert info["source"] == "cognitive-agent-bundled-assets"
|
|
assert info["safety"]["action_hold_ms"] == 720
|
|
assert info["safety"]["armed_idle_timeout_ms"] == 3100
|
|
assert info["actions"]["GUN_UP"]["action"] == "LEGREST_EXTEND"
|
|
|
|
|
|
def test_gesture_bridge_fails_closed_when_bundled_model_is_missing(tmp_path: Path):
|
|
config = tmp_path / "config" / "gesture" / "default.yaml"
|
|
config.parent.mkdir(parents=True)
|
|
config.write_text("recognition: {}\n", encoding="utf-8")
|
|
|
|
bridge = GestureCapabilityBridge(tmp_path)
|
|
info = bridge.runtime_info()
|
|
|
|
assert not bridge.available
|
|
assert not info["model_available"]
|
|
assert info["safety"]["min_action_frames"] == 8
|