From eda3a3a5403aa45a9c8e7b42b935cfde8bd8a378 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Thu, 1 Oct 2026 06:02:55 +0000 Subject: [PATCH] style: auto-format with black + isort + ruff + prettier [skip ci-format-check] --- tests/unit/test_viral_video.py | 14 ++++++++++++-- tests/unit/test_viral_video_p0.py | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/unit/test_viral_video.py b/tests/unit/test_viral_video.py index 6487d058e..dcb1f0ba8 100755 --- a/tests/unit/test_viral_video.py +++ b/tests/unit/test_viral_video.py @@ -434,7 +434,9 @@ class TestViralVideoPipeline: "negative_prompts": ["字幕", "水印"], "voiceover_script": "大家好,今天分享一款口红,颜色特别好看很显白。", } - result = _step_script_generation(mock_job, {"intent": "推广口红", "key_messages": [], "tone": "亲切"}, {"products": []}) + result = _step_script_generation( + mock_job, {"intent": "推广口红", "key_messages": [], "tone": "亲切"}, {"products": []} + ) assert isinstance(result, dict) assert "voiceover_script" in result assert "shots" in result @@ -472,7 +474,15 @@ class TestViralVideoPipeline: "overview": {"theme": "口红", "total_duration": 15, "aspect_ratio": "9:16"}, "scene_and_lighting": "明亮化妆台", "shots": [ - {"time_range": "0-15秒", "shot_type_angle_movement": "中景平视", "scene_and_dialogue": "你好分享", "action_details": "展示", "audio_bgm": "BGM", "transition": "结束", "reference_image_index": 0} + { + "time_range": "0-15秒", + "shot_type_angle_movement": "中景平视", + "scene_and_dialogue": "你好分享", + "action_details": "展示", + "audio_bgm": "BGM", + "transition": "结束", + "reference_image_index": 0, + } ], "hard_constraints": ["无字幕"], "negative_prompts": ["水印"], diff --git a/tests/unit/test_viral_video_p0.py b/tests/unit/test_viral_video_p0.py index 258225a42..6372388a7 100644 --- a/tests/unit/test_viral_video_p0.py +++ b/tests/unit/test_viral_video_p0.py @@ -72,6 +72,7 @@ class TestScriptGenerationV16: def test_fallback_script_has_required_fields(self, mock_job): from apps.worker.worker_app.tasks.viral_video import _fallback_script + out = _fallback_script(mock_job) assert isinstance(out, dict) assert "overview" in out @@ -85,18 +86,21 @@ class TestScriptGenerationV16: def test_safe_json_loads_parses_fenced_code(self): from apps.worker.worker_app.tasks.viral_video import _safe_json_loads - fenced = "```json\n{\"voiceover_script\": \"你好\", \"shots\": []}\n```" + + fenced = '```json\n{"voiceover_script": "你好", "shots": []}\n```' out = _safe_json_loads(fenced) assert out is not None assert out["voiceover_script"] == "你好" def test_safe_json_loads_handles_none(self): from apps.worker.worker_app.tasks.viral_video import _safe_json_loads + assert _safe_json_loads(None) is None assert _safe_json_loads("not json") is None def test_validate_normalize_fills_defaults(self, mock_job): from apps.worker.worker_app.tasks.viral_video import _validate_and_normalize_script + raw = {"voiceover_script": "你好", "shots": [{"scene_and_dialogue": "测试"}]} out = _validate_and_normalize_script(raw, mock_job) assert out["voiceover_script"] == "你好" @@ -106,12 +110,20 @@ class TestScriptGenerationV16: def test_assemble_seedance_prompt_contains_sections(self, mock_job): from apps.worker.worker_app.tasks.viral_video import _assemble_seedance_prompt + cr = { "overview": {"theme": "测试", "total_duration": 15, "aspect_ratio": "9:16"}, "scene_and_lighting": "明亮", "shots": [ - {"time_range": "0-15秒", "shot_type_angle_movement": "中景", "scene_and_dialogue": "你好", - "action_details": "展示", "audio_bgm": "BGM", "transition": "结束", "reference_image_index": 0} + { + "time_range": "0-15秒", + "shot_type_angle_movement": "中景", + "scene_and_dialogue": "你好", + "action_details": "展示", + "audio_bgm": "BGM", + "transition": "结束", + "reference_image_index": 0, + } ], "hard_constraints": ["无字幕"], "negative_prompts": ["水印"],