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
89 lines
2.6 KiB
Python
Executable File
89 lines
2.6 KiB
Python
Executable File
"""缩略图生成器单元测试 - 纯逻辑函数."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from video_processing.thumbnail_generator import _format_seek_time
|
|
|
|
|
|
class TestFormatSeekTime:
|
|
"""_format_seek_time 时间格式化测试."""
|
|
|
|
def test_zero_seconds(self):
|
|
"""0秒."""
|
|
result = _format_seek_time(0)
|
|
assert result == "00:00:00.00"
|
|
|
|
def test_less_than_one_second(self):
|
|
"""小于1秒."""
|
|
result = _format_seek_time(0.5)
|
|
assert result == "00:00:00.50"
|
|
|
|
def test_few_seconds(self):
|
|
"""几秒."""
|
|
result = _format_seek_time(5.5)
|
|
assert result == "00:00:05.50"
|
|
|
|
def test_one_minute(self):
|
|
"""1分钟."""
|
|
result = _format_seek_time(60.0)
|
|
assert result == "00:01:00.00"
|
|
|
|
def test_minutes_and_seconds(self):
|
|
"""分+秒."""
|
|
result = _format_seek_time(125.5)
|
|
assert result == "00:02:05.50"
|
|
|
|
def test_one_hour(self):
|
|
"""1小时."""
|
|
result = _format_seek_time(3600.0)
|
|
assert result == "01:00:00.00"
|
|
|
|
def test_hours_minutes_seconds(self):
|
|
"""时+分+秒."""
|
|
result = _format_seek_time(3725.25)
|
|
assert result == "01:02:05.25"
|
|
|
|
def test_long_duration(self):
|
|
"""长视频(2小时以上)."""
|
|
result = _format_seek_time(7384.12)
|
|
assert result == "02:03:04.12"
|
|
|
|
def test_precision_two_decimal(self):
|
|
"""两位小数精度."""
|
|
result = _format_seek_time(3.14159)
|
|
assert result == "00:00:03.14"
|
|
|
|
def test_always_two_digit_hours(self):
|
|
"""小时始终两位数字."""
|
|
result = _format_seek_time(3600 * 9)
|
|
assert result.startswith("09:")
|
|
|
|
def test_always_two_digit_minutes(self):
|
|
"""分钟始终两位数字."""
|
|
result = _format_seek_time(300) # 5分钟
|
|
parts = result.split(":")
|
|
assert parts[1] == "05"
|
|
|
|
def test_float_input(self):
|
|
"""浮点数输入."""
|
|
result = _format_seek_time(10.0)
|
|
assert isinstance(result, str)
|
|
assert result == "00:00:10.00"
|
|
|
|
def test_int_input(self):
|
|
"""整数输入."""
|
|
result = _format_seek_time(30)
|
|
assert result == "00:00:30.00"
|
|
|
|
def test_format_structure(self):
|
|
"""格式结构正确:HH:MM:SS.xx."""
|
|
result = _format_seek_time(3661.5)
|
|
# 格式: HH:MM:SS.xx
|
|
parts = result.split(":")
|
|
assert len(parts) == 3
|
|
assert "." in parts[2]
|
|
sec_parts = parts[2].split(".")
|
|
assert len(sec_parts) == 2
|
|
assert len(sec_parts[1]) == 2 # 两位小数
|