Spaces:
Sleeping
Sleeping
File size: 1,357 Bytes
4fd1504 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import pytest
import tempfile
import os
from pathlib import Path
from app import (
format_timestamp,
extract_key_phrases,
setup_spacy,
check_ffmpeg
)
def test_format_timestamp():
"""Test timestamp formatting function"""
assert format_timestamp(0) == "00:00"
assert format_timestamp(60) == "01:00"
assert format_timestamp(125) == "02:05"
assert format_timestamp(3661) == "61:01"
def test_extract_key_phrases():
"""Test key phrase extraction"""
text = "Machine learning is a powerful tool for data analysis and artificial intelligence applications."
phrases = extract_key_phrases(text, top_n=3)
assert isinstance(phrases, list)
assert len(phrases) <= 3
def test_setup_spacy():
"""Test spaCy setup"""
nlp = setup_spacy()
# Should either return a spaCy model or None
assert nlp is None or hasattr(nlp, '__call__')
def test_check_ffmpeg():
"""Test FFmpeg availability check"""
result = check_ffmpeg()
assert isinstance(result, bool)
def test_app_imports():
"""Test that the app can be imported without errors"""
try:
import app
assert hasattr(app, 'run_pipeline')
assert hasattr(app, 'create_interface')
except ImportError as e:
pytest.fail(f"Failed to import app: {e}")
if __name__ == "__main__":
pytest.main([__file__]) |