"""轮播视频的无 FFmpeg 依赖单测:时长策略是 API/前端说明的共同契约。""" from __future__ import annotations import sys import unittest from pathlib import Path SERVER_DIR = Path(__file__).resolve().parents[1] if str(SERVER_DIR) not in sys.path: sys.path.insert(0, str(SERVER_DIR)) from services.video_renderer import VideoRenderError, slide_seconds_for class SlideDurationTests(unittest.TestCase): def test_duration_strategy_for_two_to_five_images(self) -> None: self.assertEqual([slide_seconds_for(count) for count in range(2, 6)], [4.5, 3.5, 3.0, 2.8]) def test_rejects_unsupported_count(self) -> None: for count in (0, 1, 6): with self.subTest(count=count), self.assertRaises(VideoRenderError): slide_seconds_for(count) if __name__ == "__main__": unittest.main()