mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-06 00:47:47 +00:00
90ebe231ef
When duration is not reported in the files metadata, we directly infer the duration from the audio packets. This prevents errors on webm files. Very simple audio & video test files have been added that cover relevant usecases to prevent regressions.
31 lines
972 B
Python
31 lines
972 B
Python
"""Unit tests for the file service."""
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from summary.core.file_service import get_media_duration
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"filename, duration",
|
|
[
|
|
("audio-sample-android-chrome.webm", 2.2795),
|
|
("audio-sample-android-firefox.ogg", 2.3025),
|
|
("audio-sample-android.m4a", 1.38),
|
|
("audio-sample-chromium.webm", 2.65),
|
|
("audio-sample-firefox.ogg", 2.0865),
|
|
("audio-sample-ios-browser.webm", 2.6229),
|
|
("audio-sample-ios.m4a", 1.408),
|
|
("audio-sample-mac-os-safari.webm", 2.3049),
|
|
("video-sample-visio.mp4", 5.34059),
|
|
],
|
|
)
|
|
def test_validate_duration_supports_all_used_file_formats(
|
|
filename: str, duration: float
|
|
) -> None:
|
|
"""Validate duration for Safari iPhone WebM files without format duration."""
|
|
audio_path = Path(__file__).parent.parent / "assets" / filename
|
|
|
|
assert get_media_duration(audio_path) == pytest.approx(duration, 1e-3)
|