[Wake/VAD/STT 与 Live runtime]:完成真实重复语音运行,包含云端ASR/TTS开关、run-live和临时上下文测试
This commit is contained in:
@@ -57,11 +57,18 @@ class CliAcceptanceTests(unittest.TestCase):
|
||||
path = root / relative
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(b"placeholder")
|
||||
with patch("importlib.util.find_spec", return_value=object()):
|
||||
with (
|
||||
patch("importlib.util.find_spec", return_value=object()),
|
||||
patch("owner_voice_pet.cli.SherpaOnnxVadProvider") as vad_cls,
|
||||
patch("owner_voice_pet.cli.SherpaOnnxSttProvider") as stt_cls,
|
||||
):
|
||||
vad_cls.return_value.load.return_value = None
|
||||
stt_cls.return_value.load.return_value = None
|
||||
code, data = self.call("model-check", "--models-dir", str(root))
|
||||
self.assertEqual(code, 0)
|
||||
self.assertTrue(data["ok"])
|
||||
self.assertEqual(data["missing_files"], [])
|
||||
self.assertTrue(data["provider_load_checked"])
|
||||
|
||||
def test_model_check_reports_missing_files(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
@@ -77,6 +84,18 @@ class CliAcceptanceTests(unittest.TestCase):
|
||||
self.assertEqual(code, 0)
|
||||
self.assertTrue(data["ok"])
|
||||
|
||||
def test_run_live_once_invokes_runtime(self) -> None:
|
||||
class FakeRuntime:
|
||||
def run(self, *, once: bool = False):
|
||||
self.once = once
|
||||
return type("Summary", (), {"completed_turns": 1, "interrupted": False})()
|
||||
|
||||
fake_runtime = FakeRuntime()
|
||||
with patch("owner_voice_pet.cli.build_live_runtime", return_value=fake_runtime):
|
||||
code = main(["run-live", "--once"])
|
||||
self.assertEqual(code, 0)
|
||||
self.assertTrue(fake_runtime.once)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user