| 1 | """Every video generator must satisfy the VideoGenerator protocol, which |
| 2 | declares **kwargs: pipelines pass progress= callbacks, and generators that |
| 3 | reject unknown kwargs crash mid-render (TypeError) on the transition path.""" |
| 4 | |
| 5 | import inspect |
| 6 | import unittest |
| 7 | |
| 8 | from tools.video_generator_doubao_seedance_yunwu_api import VideoGeneratorDoubaoSeedanceYunwuAPI |
| 9 | from tools.video_generator_omni_yunwu_api import VideoGeneratorOmniYunwuAPI |
| 10 | from tools.video_generator_openrouter_api import VideoGeneratorOpenRouterAPI |
| 11 | from tools.video_generator_veo_google_api import VideoGeneratorVeoGoogleAPI |
| 12 | from tools.video_generator_veo_yunwu_api import VideoGeneratorVeoYunwuAPI |
| 13 | |
| 14 | |
| 15 | class TestVideoGeneratorProtocol(unittest.TestCase): |
| 16 | GENERATORS = [ |
| 17 | VideoGeneratorDoubaoSeedanceYunwuAPI, |
| 18 | VideoGeneratorOmniYunwuAPI, |
| 19 | VideoGeneratorOpenRouterAPI, |
| 20 | VideoGeneratorVeoGoogleAPI, |
| 21 | VideoGeneratorVeoYunwuAPI, |
| 22 | ] |
| 23 | |
| 24 | def test_generate_single_video_accepts_arbitrary_kwargs(self): |
| 25 | for cls in self.GENERATORS: |
| 26 | with self.subTest(cls=cls.__name__): |
| 27 | params = inspect.signature(cls.generate_single_video).parameters |
| 28 | accepts_var_kwargs = any(p.kind is inspect.Parameter.VAR_KEYWORD for p in params.values()) |
| 29 | self.assertTrue( |
| 30 | accepts_var_kwargs, |
| 31 | f"{cls.__name__}.generate_single_video must accept **kwargs per tools.protocols.VideoGenerator " |
| 32 | "(pipelines pass progress=...)", |
| 33 | ) |
| 34 | |
| 35 | |
| 36 | if __name__ == "__main__": |
| 37 | unittest.main() |
| 38 |