b1babaaedd
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Successful in 28s
CI/CD Pipeline / Frontend Lint (push) Successful in 1m54s
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 2m12s
CI/CD Pipeline / Build Staging API Image (push) Successful in 2m31s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 2m40s
CI/CD Pipeline / Unit Tests (push) Successful in 2m42s
CI/CD Pipeline / Integration Tests (push) Successful in 1m11s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 17m6s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 4m35s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 32s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 3m29s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 4m36s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
96 lines
2.9 KiB
Python
Executable File
96 lines
2.9 KiB
Python
Executable File
"""
|
|
VoiceLibraryItem 配音库领域模型单元测试
|
|
"""
|
|
|
|
from packages.domain.voice_library import VoiceLibraryItem
|
|
|
|
|
|
class TestVoiceLibraryItem:
|
|
"""VoiceLibraryItem 测试"""
|
|
|
|
def test_create_minimal(self):
|
|
item = VoiceLibraryItem(id="v1", user_id="u1", name="我的配音")
|
|
assert item.id == "v1"
|
|
assert item.user_id == "u1"
|
|
assert item.name == "我的配音"
|
|
|
|
def test_default_values(self):
|
|
item = VoiceLibraryItem(id="v1", user_id="u1", name="n")
|
|
assert item.text == ""
|
|
assert item.voice_provider == ""
|
|
assert item.voice_id == ""
|
|
assert item.voice_name == ""
|
|
assert item.audio_url == ""
|
|
assert item.duration == 0
|
|
assert item.file_size == 0
|
|
assert item.status == "completed"
|
|
assert item.project_id is None
|
|
assert item.tags == []
|
|
assert item.metadata_ == {}
|
|
|
|
def test_with_voice_info(self):
|
|
item = VoiceLibraryItem(
|
|
id="v1",
|
|
user_id="u1",
|
|
name="温柔女声",
|
|
text="大家好",
|
|
voice_provider="cosyvoice",
|
|
voice_id="longxiaochun_v3",
|
|
voice_name="龙小淳",
|
|
)
|
|
assert item.voice_provider == "cosyvoice"
|
|
assert item.voice_id == "longxiaochun_v3"
|
|
assert item.voice_name == "龙小淳"
|
|
|
|
def test_with_audio_info(self):
|
|
item = VoiceLibraryItem(
|
|
id="v1",
|
|
user_id="u1",
|
|
name="n",
|
|
audio_url="https://example.com/audio.wav",
|
|
duration=15.5,
|
|
file_size=102400,
|
|
)
|
|
assert item.audio_url == "https://example.com/audio.wav"
|
|
assert item.duration == 15.5
|
|
assert item.file_size == 102400
|
|
|
|
def test_with_project_id(self):
|
|
item = VoiceLibraryItem(
|
|
id="v1",
|
|
user_id="u1",
|
|
name="n",
|
|
project_id="proj-123",
|
|
)
|
|
assert item.project_id == "proj-123"
|
|
|
|
def test_status_values(self):
|
|
for status in ["pending", "processing", "completed", "failed"]:
|
|
item = VoiceLibraryItem(id="v1", user_id="u1", name="n", status=status)
|
|
assert item.status == status
|
|
|
|
def test_with_tags(self):
|
|
item = VoiceLibraryItem(
|
|
id="v1",
|
|
user_id="u1",
|
|
name="n",
|
|
tags=["温柔", "女声", "解说"],
|
|
)
|
|
assert len(item.tags) == 3
|
|
assert "温柔" in item.tags
|
|
|
|
def test_with_metadata(self):
|
|
item = VoiceLibraryItem(
|
|
id="v1",
|
|
user_id="u1",
|
|
name="n",
|
|
metadata_={"speed": 1.0, "pitch": 0.5},
|
|
)
|
|
assert item.metadata_["speed"] == 1.0
|
|
assert item.metadata_["pitch"] == 0.5
|
|
|
|
def test_has_timestamps(self):
|
|
item = VoiceLibraryItem(id="v1", user_id="u1", name="n")
|
|
assert item.created_at is not None
|
|
assert item.updated_at is not None
|