feat: professionalize control plane and standalone delivery
This commit is contained in:
80
tests/test_settings_service.py
Normal file
80
tests/test_settings_service.py
Normal file
@ -0,0 +1,80 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from biliup_next.core.config import SettingsService
|
||||
|
||||
|
||||
class SettingsServiceTests(unittest.TestCase):
|
||||
def test_load_seeds_settings_from_standalone_example_when_missing(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
config_dir = root / "config"
|
||||
config_dir.mkdir(parents=True, exist_ok=True)
|
||||
(config_dir / "settings.schema.json").write_text(
|
||||
"""
|
||||
{
|
||||
"groups": {
|
||||
"runtime": {
|
||||
"database_path": {"type": "string", "default": "data/workspace/biliup_next.db"}
|
||||
},
|
||||
"paths": {
|
||||
"stage_dir": {"type": "string", "default": "data/workspace/stage"},
|
||||
"backup_dir": {"type": "string", "default": "data/workspace/backup"},
|
||||
"session_dir": {"type": "string", "default": "data/workspace/session"},
|
||||
"cookies_file": {"type": "string", "default": "runtime/cookies.json"},
|
||||
"upload_config_file": {"type": "string", "default": "runtime/upload_config.json"}
|
||||
},
|
||||
"ingest": {
|
||||
"ffprobe_bin": {"type": "string", "default": "ffprobe"}
|
||||
},
|
||||
"transcribe": {
|
||||
"ffmpeg_bin": {"type": "string", "default": "ffmpeg"}
|
||||
},
|
||||
"split": {
|
||||
"ffmpeg_bin": {"type": "string", "default": "ffmpeg"}
|
||||
},
|
||||
"song_detect": {
|
||||
"codex_cmd": {"type": "string", "default": "codex"}
|
||||
},
|
||||
"publish": {
|
||||
"biliup_path": {"type": "string", "default": "runtime/biliup"},
|
||||
"cookie_file": {"type": "string", "default": "runtime/cookies.json"}
|
||||
}
|
||||
}
|
||||
}
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(config_dir / "settings.standalone.example.json").write_text(
|
||||
"""
|
||||
{
|
||||
"runtime": {"database_path": "data/workspace/biliup_next.db"},
|
||||
"paths": {
|
||||
"stage_dir": "data/workspace/stage",
|
||||
"backup_dir": "data/workspace/backup",
|
||||
"session_dir": "data/workspace/session",
|
||||
"cookies_file": "runtime/cookies.json",
|
||||
"upload_config_file": "runtime/upload_config.json"
|
||||
},
|
||||
"ingest": {"ffprobe_bin": "ffprobe"},
|
||||
"transcribe": {"ffmpeg_bin": "ffmpeg"},
|
||||
"split": {"ffmpeg_bin": "ffmpeg"},
|
||||
"song_detect": {"codex_cmd": "codex"},
|
||||
"publish": {"biliup_path": "runtime/biliup", "cookie_file": "runtime/cookies.json"}
|
||||
}
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
bundle = SettingsService(root).load()
|
||||
|
||||
self.assertTrue((config_dir / "settings.json").exists())
|
||||
self.assertTrue((config_dir / "settings.staged.json").exists())
|
||||
self.assertEqual(bundle.settings["paths"]["cookies_file"], str((root / "runtime" / "cookies.json").resolve()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user