7a72cfd709
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 2m9s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 2m19s
CI/CD Pipeline / Validate - Code Quality (push) Failing after 3m10s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 3m7s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 3m7s
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 1m17s
CI/CD Pipeline / Frontend Lint (push) Successful in 3m37s
CI/CD Pipeline / Integration Tests (push) Successful in 2m18s
CI/CD Pipeline / Unit Tests (push) Failing after 4m59s
CI/CD Pipeline / Build Staging API Image (push) Successful in 8m39s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 3m25s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 42s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 27m2s
CI/CD Pipeline / Staging API Integration Tests (push) Failing after 30m15s
112 lines
3.7 KiB
Python
Executable File
112 lines
3.7 KiB
Python
Executable File
"""BGM混音单元测试 - 配置解析等纯逻辑."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from video_processing.bgm_mixer import BGMConfig
|
|
|
|
|
|
class TestBGMConfigDefaults:
|
|
"""BGMConfig 默认值测试."""
|
|
|
|
def test_default_values(self):
|
|
"""默认值正确."""
|
|
config = BGMConfig(bgm_path="/bgm.mp3")
|
|
assert config.bgm_path == "/bgm.mp3"
|
|
assert config.volume == 0.3
|
|
assert config.fade_in == 0.0
|
|
assert config.fade_out == 0.0
|
|
assert config.loop_enabled is True
|
|
assert config.sidechain_enabled is False
|
|
assert config.sidechain_ratio == 0.3
|
|
assert config.sidechain_attack == 0.02
|
|
assert config.sidechain_release == 0.5
|
|
assert config.sidechain_threshold == -25.0
|
|
|
|
|
|
class TestBGMConfigFromConfigDict:
|
|
"""BGMConfig.from_config_dict 解析测试."""
|
|
|
|
def test_empty_dict_defaults(self):
|
|
"""空字典用默认值."""
|
|
config = BGMConfig.from_config_dict("/bgm.mp3", {})
|
|
assert config.bgm_path == "/bgm.mp3"
|
|
assert config.volume == 0.3
|
|
assert config.loop_enabled is True
|
|
assert config.sidechain_enabled is False
|
|
|
|
def test_custom_volume(self):
|
|
"""自定义音量."""
|
|
config = BGMConfig.from_config_dict("/a.mp3", {"volume": 0.5})
|
|
assert config.volume == 0.5
|
|
|
|
def test_fade_in_out(self):
|
|
"""淡入淡出."""
|
|
config = BGMConfig.from_config_dict(
|
|
"/a.mp3",
|
|
{
|
|
"fade_in": 2.0,
|
|
"fade_out": 3.0,
|
|
},
|
|
)
|
|
assert config.fade_in == 2.0
|
|
assert config.fade_out == 3.0
|
|
|
|
def test_loop_disabled(self):
|
|
"""禁用循环."""
|
|
config = BGMConfig.from_config_dict("/a.mp3", {"loop_enabled": False})
|
|
assert config.loop_enabled is False
|
|
|
|
def test_sidechain_enabled(self):
|
|
"""启用人声闪避."""
|
|
config = BGMConfig.from_config_dict("/a.mp3", {"sidechain_enabled": True})
|
|
assert config.sidechain_enabled is True
|
|
|
|
def test_sidechain_custom_params(self):
|
|
"""闪避自定义参数."""
|
|
config = BGMConfig.from_config_dict(
|
|
"/a.mp3",
|
|
{
|
|
"sidechain_enabled": True,
|
|
"sidechain_ratio": 0.5,
|
|
"sidechain_attack": 0.05,
|
|
"sidechain_release": 0.8,
|
|
"sidechain_threshold": -30.0,
|
|
},
|
|
)
|
|
assert config.sidechain_ratio == 0.5
|
|
assert config.sidechain_attack == 0.05
|
|
assert config.sidechain_release == 0.8
|
|
assert config.sidechain_threshold == -30.0
|
|
|
|
def test_bgm_path_preserved(self):
|
|
"""bgm_path保持不变."""
|
|
config = BGMConfig.from_config_dict("/custom/path.mp3", {"volume": 0.5})
|
|
assert config.bgm_path == "/custom/path.mp3"
|
|
|
|
def test_all_params_custom(self):
|
|
"""所有参数自定义."""
|
|
config = BGMConfig.from_config_dict(
|
|
"/full.mp3",
|
|
{
|
|
"volume": 0.7,
|
|
"fade_in": 1.5,
|
|
"fade_out": 2.0,
|
|
"loop_enabled": False,
|
|
"sidechain_enabled": True,
|
|
"sidechain_ratio": 0.4,
|
|
"sidechain_attack": 0.03,
|
|
"sidechain_release": 0.6,
|
|
"sidechain_threshold": -20.0,
|
|
},
|
|
)
|
|
assert config.volume == 0.7
|
|
assert config.fade_in == 1.5
|
|
assert config.fade_out == 2.0
|
|
assert config.loop_enabled is False
|
|
assert config.sidechain_enabled is True
|
|
assert config.sidechain_ratio == 0.4
|
|
assert config.sidechain_attack == 0.03
|
|
assert config.sidechain_release == 0.6
|
|
assert config.sidechain_threshold == -20.0
|