Files
moma/renamer/test/test_mediainfo_frame_class.py
T
sha 8274cb4e9f feat: Add conversion and deletion confirmation screens, enhance media panel properties
- Implemented ConvertConfirmScreen for confirming AVI to MKV conversions with audio and subtitle options.
- Added DeleteConfirmScreen for confirming file deletions with detailed file information.
- Enhanced MediaPanelView to include additional MediaInfo properties such as video, audio, and subtitle tracks.
- Updated MediaPanelProperties to extract and display raw MediaInfo track data.
- Introduced HelpScreen for user guidance on application features and navigation.
- Created OpenScreen for directory path input with validation.
- Developed RenameConfirmScreen for renaming files with user confirmation and editing capabilities.
- Added SettingsScreen for configuring application settings, including cache TTL and HEVC encoding options.
- Updated imports and module exports in views to accommodate new screens.
2026-04-11 20:49:28 +03:00

48 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Test script for MediaInfo frame class detection by resolution"""
import json
import pytest
from unittest.mock import MagicMock
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from renamer.extractors.mediainfo_extractor import MediaInfoExtractor
from pathlib import Path
# Load test cases from dataset using context manager
test_cases_file = Path(__file__).parent / 'datasets' / 'mediainfo' / 'frame_class_tests.json'
with open(test_cases_file, 'r', encoding='utf-8') as f:
test_cases = json.load(f)
@pytest.mark.parametrize("test_case", test_cases, ids=[tc['testname'] for tc in test_cases])
def test_frame_class_detection(test_case):
"""Test frame class detection for various resolutions"""
testname = test_case['testname']
width, height = test_case['resolution']
interlaced = test_case['interlaced']
expected = test_case['expected_frame_class']
# Create a mock MediaInfoExtractor
extractor = MagicMock(spec=MediaInfoExtractor)
from pathlib import Path
extractor.file_path = Path(f"test_{testname}") # Set a unique file_path for caching
# Mock the video_tracks
mock_track = MagicMock()
mock_track.height = height
mock_track.width = width
mock_track.interlaced = 'Yes' if interlaced else 'No'
extractor.video_tracks = [mock_track]
extractor.extract_resolution.return_value = (height, width)
extractor._video_tracks.return_value = [mock_track]
extractor.extract_interlaced.return_value = interlaced
# Test the method
actual = MediaInfoExtractor.extract_frame_class(extractor)
assert actual == expected, f"{testname}: expected {expected}, got {actual}"