Merge pull request #21012 from stephenschoettler/fix/ci-pr-check-unblock

fix(ci): unblock shared PR checks
This commit is contained in:
ethernet 2026-05-14 16:16:42 -04:00 committed by GitHub
commit cd64bed55e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 194 additions and 70 deletions

View file

@ -5,7 +5,7 @@ import threading
from pathlib import Path
from unittest.mock import patch
from tools.registry import ToolRegistry, discover_builtin_tools
from tools.registry import ToolRegistry, _module_registers_tools, discover_builtin_tools
def _dummy_handler(args, **kwargs):
@ -289,43 +289,19 @@ class TestCheckFnExceptionHandling:
class TestBuiltinDiscovery:
def test_matches_previous_manual_builtin_tool_set(self):
expected = {
"tools.browser_cdp_tool",
"tools.browser_dialog_tool",
"tools.browser_tool",
"tools.clarify_tool",
"tools.code_execution_tool",
"tools.computer_use_tool",
"tools.cronjob_tools",
"tools.delegate_tool",
"tools.discord_tool",
"tools.feishu_doc_tool",
"tools.feishu_drive_tool",
"tools.file_tools",
"tools.homeassistant_tool",
"tools.image_generation_tool",
"tools.kanban_tools",
"tools.memory_tool",
"tools.mixture_of_agents_tool",
"tools.process_registry",
"tools.rl_training_tool",
"tools.send_message_tool",
"tools.session_search_tool",
"tools.skill_manager_tool",
"tools.skills_tool",
"tools.terminal_tool",
"tools.todo_tool",
"tools.tts_tool",
"tools.vision_tools",
"tools.web_tools",
"tools.yuanbao_tools",
}
def test_discovers_all_real_self_registering_builtin_tool_modules(self):
tools_dir = Path(__file__).resolve().parents[2] / "tools"
expected = [
f"tools.{path.stem}"
for path in sorted(tools_dir.glob("*.py"))
if path.name not in {"__init__.py", "registry.py", "mcp_tool.py"}
and _module_registers_tools(path)
]
with patch("tools.registry.importlib.import_module"):
imported = discover_builtin_tools(Path(__file__).resolve().parents[2] / "tools")
imported = discover_builtin_tools(tools_dir)
assert set(imported) == expected
assert imported == expected
def test_imports_only_self_registering_modules(self, tmp_path):
tools_dir = tmp_path / "tools"

View file

@ -8,11 +8,16 @@ import json
import os
import tempfile
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import MagicMock, patch, mock_open
import pytest
def _fake_faster_whisper_module(mock_model):
return SimpleNamespace(WhisperModel=MagicMock(return_value=mock_model))
# ---------------------------------------------------------------------------
# Provider selection
# ---------------------------------------------------------------------------
@ -137,8 +142,9 @@ class TestTranscribeLocal:
mock_model = MagicMock()
mock_model.transcribe.return_value = ([mock_segment], mock_info)
fake_fw = _fake_faster_whisper_module(mock_model)
with patch("tools.transcription_tools._HAS_FASTER_WHISPER", True), \
patch("faster_whisper.WhisperModel", return_value=mock_model), \
patch.dict("sys.modules", {"faster_whisper": fake_fw}), \
patch("tools.transcription_tools._local_model", None):
from tools.transcription_tools import _transcribe_local
result = _transcribe_local(str(audio_file), "base")
@ -300,7 +306,8 @@ class TestNormalizeLocalModel:
}), \
patch("tools.transcription_tools._local_model", None), \
patch("tools.transcription_tools._local_model_name", None), \
patch("faster_whisper.WhisperModel", return_value=mock_model) as mock_cls:
patch.dict("sys.modules", {"faster_whisper": _fake_faster_whisper_module(mock_model)}):
mock_cls = __import__("faster_whisper").WhisperModel
from tools.transcription_tools import transcribe_audio
transcribe_audio(audio_file)
# WhisperModel must NOT have been called with "whisper-1"

View file

@ -3,7 +3,6 @@
import json
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
@ -27,7 +26,7 @@ def mock_kittentts_module():
"""Inject a fake kittentts + soundfile module that return stub objects."""
fake_model = MagicMock()
# 24kHz float32 PCM at ~2s of silence
fake_model.generate.return_value = np.zeros(48000, dtype=np.float32)
fake_model.generate.return_value = [0.0] * 48000
fake_cls = MagicMock(return_value=fake_model)
fake_kittentts = MagicMock()
fake_kittentts.KittenTTS = fake_cls