Files
xiaoxia-saas/tests/unit/test_thumbnail_generator.py
T
CI Bot 2df7bc9dc8
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 1m41s
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 / Build Staging Web Image (push) Successful in 1m45s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 1m54s
CI/CD Pipeline / Validate - Code Quality (push) Failing after 3m1s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 1m34s
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 5m49s
CI/CD Pipeline / Frontend Lint (push) Successful in 6m0s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 4m27s
CI/CD Pipeline / Integration Tests (push) Successful in 2m20s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m11s
CI/CD Pipeline / Unit Tests (push) Failing after 5m52s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 30s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 1m48s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 5m10s
style: auto-format with black + isort + prettier
2026-07-24 13:35:05 +00:00

61 lines
1.6 KiB
Python
Executable File

"""
缩略图生成器纯函数测试.
覆盖 _format_seek_time 等纯逻辑.
FFmpeg 抽帧与 OSS 上传由集成测试覆盖.
"""
from __future__ import annotations
import pytest
from video_processing.thumbnail_generator import _format_seek_time
class TestFormatSeekTime:
"""_format_seek_time 时间格式化."""
def test_zero(self):
assert _format_seek_time(0.0) == "00:00:00.00"
def test_seconds_only(self):
assert _format_seek_time(5.5) == "00:00:05.50"
def test_minutes(self):
assert _format_seek_time(65.25) == "00:01:05.25"
def test_hours(self):
assert _format_seek_time(3661.5) == "01:01:01.50"
def test_exact_minute(self):
assert _format_seek_time(60.0) == "00:01:00.00"
def test_exact_hour(self):
assert _format_seek_time(3600.0) == "01:00:00.00"
def test_very_short(self):
assert _format_seek_time(0.1) == "00:00:00.10"
def test_long_video(self):
# 超过1小时
assert _format_seek_time(7200.0) == "02:00:00.00"
def test_sub_second_precision(self):
result = _format_seek_time(1.234)
parts = result.split(":")
assert len(parts) == 3
sec_part = parts[2]
assert "." in sec_part
decimals = sec_part.split(".")[1]
assert len(decimals) == 2
def test_zero_padded_hours(self):
# 小时始终是2位
result = _format_seek_time(5.0)
assert result.startswith("00:")
def test_zero_padded_minutes(self):
# 分钟始终是2位
result = _format_seek_time(5.0)
parts = result.split(":")
assert len(parts[1]) == 2