test(ci): 修复10个ruff错误 + Unit Tests dedup收集失败 (#839 #881)
AI Code Review / AI Code Review (pull_request) Failing after 0s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 15s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 46s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m40s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m41s
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m6s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 28s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m51s
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m37s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 2m32s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 4m55s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m18s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 11s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Failing after 11s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m51s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 48m44s
AI Code Review / AI Code Review (pull_request) Failing after 0s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 15s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 46s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m40s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m41s
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m6s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 28s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m51s
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m37s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 2m32s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 4m55s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m18s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 11s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Failing after 11s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m51s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 48m44s
This commit is contained in:
@@ -10,6 +10,9 @@ import pytest
|
||||
|
||||
# 模块级mock cv2(dedup模块import时需要)
|
||||
sys.modules["cv2"] = MagicMock()
|
||||
# 模块级mock worker_app.db(dedup模块import时会触发数据库初始化,纯算法测试不需要)
|
||||
sys.modules["worker_app.db"] = MagicMock()
|
||||
sys.modules["worker_app.db"].SessionLocal = MagicMock()
|
||||
|
||||
from video_processing.dedup import ( # noqa: E402
|
||||
VideoDeduplicator,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from dataclasses import FrozenInstanceError
|
||||
|
||||
"""domain 层剩余小模块单测 - bgm_utils/exceptions/editing_mode/recipe/template/template_version/template_clip_config/preset_bgm/preset_voices/title_library/voice_library"""
|
||||
|
||||
import pytest
|
||||
@@ -397,7 +399,7 @@ class TestPresetBGM:
|
||||
|
||||
def test_preset_bgm_frozen(self):
|
||||
bgm = PresetBGM(id="t1", name="t", style="x", duration=10.0)
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(FrozenInstanceError):
|
||||
bgm.name = "改名"
|
||||
|
||||
def test_library_not_empty(self):
|
||||
@@ -487,7 +489,7 @@ class TestPresetVoices:
|
||||
|
||||
def test_preset_voice_frozen(self):
|
||||
v = PresetVoice(voice_id="v1", name="t", description="d", gender="female")
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(FrozenInstanceError):
|
||||
v.name = "改名"
|
||||
|
||||
def test_preset_voices_list_not_empty(self):
|
||||
|
||||
@@ -267,4 +267,4 @@ class TestGetEmailService:
|
||||
svc1 = get_email_service()
|
||||
svc2 = get_email_service()
|
||||
# 两个都可能是 Noop 或 EmailService,取决于环境
|
||||
assert type(svc1) == type(svc2)
|
||||
assert type(svc1) is type(svc2)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from dataclasses import FrozenInstanceError
|
||||
|
||||
"""filter_presets 领域层单元测试 - 滤镜预设库"""
|
||||
|
||||
import pytest
|
||||
@@ -58,7 +60,7 @@ class TestFilterPreset:
|
||||
def test_frozen_immutable(self):
|
||||
"""frozen dataclass 不可修改"""
|
||||
preset = FilterPreset(id="test", name="测试", category="basic")
|
||||
with pytest.raises(Exception): # FrozenInstanceError
|
||||
with pytest.raises(FrozenInstanceError):
|
||||
preset.name = "改名"
|
||||
|
||||
def test_tags_default_empty_list(self):
|
||||
|
||||
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
import time
|
||||
|
||||
import pytest
|
||||
from jwt.exceptions import ExpiredSignatureError, InvalidTokenError
|
||||
|
||||
from packages.application.auth.jwt_handler import (
|
||||
JWTHandler,
|
||||
@@ -86,17 +87,17 @@ class TestJWTHandler:
|
||||
# 等待一小段时间确保过期
|
||||
time.sleep(0.1)
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(ExpiredSignatureError):
|
||||
handler.verify_access_token(token)
|
||||
|
||||
def test_invalid_token_raises_error(self, jwt_handler):
|
||||
"""无效 token 验证失败"""
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(InvalidTokenError):
|
||||
jwt_handler.verify_access_token("invalid.token.here")
|
||||
|
||||
def test_empty_token_raises_error(self, jwt_handler):
|
||||
"""空字符串 token 验证失败"""
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(InvalidTokenError):
|
||||
jwt_handler.verify_access_token("")
|
||||
|
||||
def test_different_secret_fails_verification(self):
|
||||
@@ -106,7 +107,7 @@ class TestJWTHandler:
|
||||
|
||||
token = handler1.create_access_token(user_id="user_001")
|
||||
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(InvalidTokenError):
|
||||
handler2.verify_access_token(token)
|
||||
|
||||
def test_custom_algorithm(self):
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from dataclasses import FrozenInstanceError
|
||||
|
||||
"""transition_presets 领域层单元测试 - 转场预设库"""
|
||||
|
||||
import pytest
|
||||
@@ -50,7 +52,7 @@ class TestTransitionPreset:
|
||||
def test_frozen_immutable(self):
|
||||
"""frozen dataclass 不可修改"""
|
||||
preset = TransitionPreset(id="test", name="测试", category="basic")
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises(FrozenInstanceError):
|
||||
preset.name = "改名"
|
||||
|
||||
def test_tags_default_empty_list(self):
|
||||
@@ -78,7 +80,7 @@ class TestTransitionPresetLibrary:
|
||||
def test_all_presets_have_required_fields(self):
|
||||
"""所有预设都有必填字段"""
|
||||
for preset in TRANSITION_PRESET_LIBRARY:
|
||||
assert preset.id, f"missing id"
|
||||
assert preset.id, "missing id"
|
||||
assert preset.name, f"{preset.id} missing name"
|
||||
assert preset.category, f"{preset.id} missing category"
|
||||
assert preset.transition, f"{preset.id} missing transition"
|
||||
|
||||
Reference in New Issue
Block a user