Fix Pro config SSOT, event FSM, FFmpeg error tiers, relay heartbeat, and ingest auth while keeping relay snapshot, quality guard, and event hub hidden in the UI. Co-authored-by: Cursor <cursoragent@cursor.com>
80 lines
3.5 KiB
Python
80 lines
3.5 KiB
Python
from __future__ import annotations
|
|
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from src.youtube_config_paths import is_youtube_pro_pm2, resolve_youtube_style_config_paths
|
|
|
|
|
|
class YoutubeConfigPathTests(unittest.TestCase):
|
|
def test_non_youtube_process_uses_legacy_paths(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
cfg = root / "config"
|
|
cfg.mkdir(parents=True, exist_ok=True)
|
|
yt, url = resolve_youtube_style_config_paths(root, "tiktok")
|
|
self.assertEqual(yt, str(cfg / "youtube.ini"))
|
|
self.assertEqual(url, str(cfg / "URL_config.ini"))
|
|
|
|
def test_youtube_process_uses_legacy_pair_when_only_legacy_exists(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
cfg = root / "config"
|
|
cfg.mkdir(parents=True, exist_ok=True)
|
|
(cfg / "youtube.ini").write_text("[youtube]\nkey = legacy\n", encoding="utf-8")
|
|
(cfg / "URL_config.ini").write_text("https://live.douyin.com/1\n", encoding="utf-8")
|
|
|
|
yt, url = resolve_youtube_style_config_paths(root, "youtube")
|
|
|
|
self.assertEqual(yt, str(cfg / "youtube.ini"))
|
|
self.assertEqual(url, str(cfg / "URL_config.ini"))
|
|
|
|
def test_youtube_process_falls_back_per_file_when_only_managed_url_exists(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
cfg = root / "config"
|
|
cfg.mkdir(parents=True, exist_ok=True)
|
|
(cfg / "youtube.ini").write_text("[youtube]\nkey = legacy\n", encoding="utf-8")
|
|
managed_url = cfg / "URL_config.youtube.ini"
|
|
managed_url.write_text("https://live.douyin.com/2\n", encoding="utf-8")
|
|
|
|
yt, url = resolve_youtube_style_config_paths(root, "youtube")
|
|
|
|
self.assertEqual(yt, str(cfg / "youtube.ini"))
|
|
self.assertEqual(url, str(managed_url))
|
|
|
|
def test_youtube_process_falls_back_per_file_when_only_managed_youtube_ini_exists(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
cfg = root / "config"
|
|
cfg.mkdir(parents=True, exist_ok=True)
|
|
managed_yt = cfg / "youtube.youtube.ini"
|
|
managed_yt.write_text("[youtube]\nkey = managed\n", encoding="utf-8")
|
|
(cfg / "URL_config.ini").write_text("https://live.douyin.com/3\n", encoding="utf-8")
|
|
|
|
yt, url = resolve_youtube_style_config_paths(root, "youtube")
|
|
|
|
self.assertEqual(yt, str(managed_yt))
|
|
self.assertEqual(url, str(cfg / "URL_config.ini"))
|
|
|
|
def test_pro_lane_never_falls_back_to_legacy_url(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
root = Path(tmp)
|
|
cfg = root / "config"
|
|
cfg.mkdir(parents=True, exist_ok=True)
|
|
(cfg / "youtube.ini").write_text("[youtube]\nkey = legacy\n", encoding="utf-8")
|
|
(cfg / "URL_config.ini").write_text("https://live.douyin.com/legacy\n", encoding="utf-8")
|
|
managed_yt = cfg / "youtube.youtube2__lane1.ini"
|
|
managed_yt.write_text("[youtube]\nkey = lane1\n", encoding="utf-8")
|
|
|
|
yt, url = resolve_youtube_style_config_paths(root, "youtube2__lane1")
|
|
|
|
self.assertEqual(yt, str(managed_yt))
|
|
self.assertEqual(url, str(cfg / "URL_config.youtube2__lane1.ini"))
|
|
self.assertTrue(is_youtube_pro_pm2("youtube2__lane1"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|