mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 11:33:25 +00:00
feat: add frame class extraction and formatting for media files
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from ..extractors.filename_extractor import FilenameExtractor
|
||||
from ..constants import FRAME_CLASSES
|
||||
|
||||
|
||||
def load_test_filenames():
|
||||
@@ -17,6 +18,9 @@ def test_extract_title(filename):
|
||||
"""Test title extraction from filename"""
|
||||
file_path = Path(filename)
|
||||
title = FilenameExtractor.extract_title(file_path)
|
||||
# Print filename and extracted title clearly
|
||||
print(f"\nFilename: \033[1;36m{filename}\033[0m")
|
||||
print(f"Extracted title: \033[1;32m{title}\033[0m")
|
||||
# For now, just check it's not None and is string
|
||||
assert isinstance(title, str) or title is None
|
||||
|
||||
@@ -39,15 +43,23 @@ def test_extract_source(filename):
|
||||
"""Test source extraction from filename"""
|
||||
file_path = Path(filename)
|
||||
source = FilenameExtractor.extract_source(file_path)
|
||||
# Print filename and extracted source clearly
|
||||
print(f"\nFilename: \033[1;36m{filename}\033[0m")
|
||||
print(f"Extracted source: \033[1;32m{source}\033[0m")
|
||||
# Source should be None or string
|
||||
assert isinstance(source, str) or source is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("filename", load_test_filenames())
|
||||
def test_extract_resolution(filename):
|
||||
"""Test resolution extraction from filename"""
|
||||
def test_extract_frame_class(filename):
|
||||
"""Test frame class extraction from filename"""
|
||||
file_path = Path(filename)
|
||||
resolution = FilenameExtractor.extract_resolution(file_path)
|
||||
# Resolution should be None or string like '2160p'
|
||||
if resolution:
|
||||
assert 'p' in resolution or 'i' in resolution
|
||||
frame_class = FilenameExtractor.extract_frame_class(file_path)
|
||||
# Print filename and extracted frame class clearly
|
||||
print(f"\nFilename: \033[1;36m{filename}\033[0m")
|
||||
print(f"Extracted frame_class: \033[1;32m{frame_class}\033[0m")
|
||||
# Frame class should be a string
|
||||
assert isinstance(frame_class, str)
|
||||
# Should be one of the valid frame classes or 'Unclassified'
|
||||
valid_classes = set(FRAME_CLASSES.keys()) | {'Unclassified'}
|
||||
assert frame_class in valid_classes
|
||||
Reference in New Issue
Block a user