[依赖、模型和配置]:完成本地语音模型准备,包含.env配置、模型下载脚本和model-check
This commit is contained in:
@@ -2,10 +2,14 @@ from __future__ import annotations
|
||||
|
||||
import io
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
from contextlib import redirect_stdout
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from owner_voice_pet.cli import main
|
||||
from owner_voice_pet.speech_models import REQUIRED_MODEL_FILES, write_default_manifest
|
||||
|
||||
|
||||
class CliAcceptanceTests(unittest.TestCase):
|
||||
@@ -45,6 +49,28 @@ class CliAcceptanceTests(unittest.TestCase):
|
||||
self.assertEqual(code, 0)
|
||||
self.assertEqual(data["secret_leaks"], [])
|
||||
|
||||
def test_model_check_reports_manifest_and_files(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
write_default_manifest(root)
|
||||
for relative in REQUIRED_MODEL_FILES:
|
||||
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()):
|
||||
code, data = self.call("model-check", "--models-dir", str(root))
|
||||
self.assertEqual(code, 0)
|
||||
self.assertTrue(data["ok"])
|
||||
self.assertEqual(data["missing_files"], [])
|
||||
|
||||
def test_model_check_reports_missing_files(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
with patch("importlib.util.find_spec", return_value=object()):
|
||||
code, data = self.call("model-check", "--models-dir", tmp)
|
||||
self.assertEqual(code, 1)
|
||||
self.assertFalse(data["ok"])
|
||||
self.assertTrue(data["missing_files"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -69,6 +69,7 @@ class ModelsConfigTests(unittest.TestCase):
|
||||
self.assertEqual(config.llm_base_url, "https://newapi.mkbk.shop")
|
||||
self.assertEqual(config.llm_api_key, "secret-value")
|
||||
self.assertEqual(config.llm_model, "test-model")
|
||||
self.assertEqual(str(config.speech_models_dir), "models")
|
||||
self.assertTrue(config.llm_stream)
|
||||
self.assertEqual(config.validate_basic(), [])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user