From 2b3f1801d4deb9269f413b1436df4b102111dcab Mon Sep 17 00:00:00 2001 From: CI Bot Date: Mon, 31 Aug 2026 09:50:22 +0000 Subject: [PATCH] style: auto-format with black + isort + prettier [skip ci-format-check] --- ...grate_template_segments_to_clip_configs.py | 6 ++-- tests/unit/test_unify_template_segments.py | 34 +++++++------------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/alembic/versions/060_migrate_template_segments_to_clip_configs.py b/alembic/versions/060_migrate_template_segments_to_clip_configs.py index aa20a3c02..d9af83ac1 100644 --- a/alembic/versions/060_migrate_template_segments_to_clip_configs.py +++ b/alembic/versions/060_migrate_template_segments_to_clip_configs.py @@ -28,16 +28,14 @@ def upgrade() -> None: conn = op.get_bind() # 找出有旧数据但没有新数据的 template_id - rows = conn.execute( - """ + rows = conn.execute(""" SELECT ts.id, ts.template_id, ts.segment_order, ts.duration_min, ts.duration_max, ts.material_type FROM template_segments ts WHERE ts.template_id NOT IN ( SELECT DISTINCT tcc.template_id FROM template_clip_configs tcc ) ORDER BY ts.template_id, ts.segment_order - """ - ) + """) for row in rows: config = {"material_type": row[5]} if row[5] else {} diff --git a/tests/unit/test_unify_template_segments.py b/tests/unit/test_unify_template_segments.py index 9a73e703e..ed4db7ac9 100644 --- a/tests/unit/test_unify_template_segments.py +++ b/tests/unit/test_unify_template_segments.py @@ -57,9 +57,7 @@ class TestCreateSegmentsWritesToClipConfigs: repo.create_segments([seg]) # 验证 template_clip_configs 有记录 - clips = db_session.query(TemplateClipConfigModel).filter( - TemplateClipConfigModel.template_id == tpl.id - ).all() + clips = db_session.query(TemplateClipConfigModel).filter(TemplateClipConfigModel.template_id == tpl.id).all() assert len(clips) == 1 assert clips[0].order == 0 assert clips[0].min_duration == 3.0 @@ -74,9 +72,7 @@ class TestCreateSegmentsWritesToClipConfigs: seg = _make_segment(tpl.id, 0) repo.create_segments([seg]) - old_rows = db_session.query(TemplateSegmentModel).filter( - TemplateSegmentModel.template_id == tpl.id - ).all() + old_rows = db_session.query(TemplateSegmentModel).filter(TemplateSegmentModel.template_id == tpl.id).all() assert len(old_rows) == 0 @@ -183,9 +179,7 @@ class TestDeleteSegments: count = repo.delete_segments_by_template(tpl.id) assert count == 1 - clips = db_session.query(TemplateClipConfigModel).filter( - TemplateClipConfigModel.template_id == tpl.id - ).all() + clips = db_session.query(TemplateClipConfigModel).filter(TemplateClipConfigModel.template_id == tpl.id).all() assert len(clips) == 0 def test_delete_template_clears_both_tables(self, repo: SQLAlchemyTemplateRepository, db_session: Session): @@ -206,14 +200,10 @@ class TestDeleteSegments: repo.delete(tpl.id, "user1") - clips = db_session.query(TemplateClipConfigModel).filter( - TemplateClipConfigModel.template_id == tpl.id - ).all() + clips = db_session.query(TemplateClipConfigModel).filter(TemplateClipConfigModel.template_id == tpl.id).all() assert len(clips) == 0 - old_rows = db_session.query(TemplateSegmentModel).filter( - TemplateSegmentModel.template_id == tpl.id - ).all() + old_rows = db_session.query(TemplateSegmentModel).filter(TemplateSegmentModel.template_id == tpl.id).all() assert len(old_rows) == 0 @@ -223,10 +213,12 @@ class TestCopyTemplateSegments: def test_copy_preserves_segments(self, repo: SQLAlchemyTemplateRepository, db_session: Session): tpl = _make_template() repo.create(tpl) - repo.create_segments([ - _make_segment(tpl.id, 0, "video"), - _make_segment(tpl.id, 1, "voiceover"), - ]) + repo.create_segments( + [ + _make_segment(tpl.id, 0, "video"), + _make_segment(tpl.id, 1, "voiceover"), + ] + ) copied = repo.copy_template(tpl.id, "user1", "copy") assert len(copied.segments) == 2 @@ -234,9 +226,7 @@ class TestCopyTemplateSegments: assert copied.segments[1].material_type == "voiceover" # 验证新模板的 clip_configs 有数据 - clips = db_session.query(TemplateClipConfigModel).filter( - TemplateClipConfigModel.template_id == copied.id - ).all() + clips = db_session.query(TemplateClipConfigModel).filter(TemplateClipConfigModel.template_id == copied.id).all() assert len(clips) == 2