Add comprehensive tests for formatter classes, services, and utilities

- Introduced tests for various formatter classes including TextFormatter, DurationFormatter, SizeFormatter, DateFormatter, and more to ensure correct formatting behavior.
- Added tests for service classes such as FileTreeService, MetadataService, and RenameService, covering directory validation, metadata extraction, and file renaming functionalities.
- Implemented utility tests for LanguageCodeExtractor, PatternExtractor, and FrameClassMatcher to validate their extraction and matching capabilities.
- Updated test cases to use datasets for better maintainability and clarity.
- Enhanced error handling tests to ensure robustness against missing or invalid data.
This commit is contained in:
sha
2025-12-31 14:04:33 +00:00
parent c5fbd367fc
commit 262c0a7b7d
45 changed files with 3346 additions and 1057 deletions
+8 -3
View File
@@ -4,13 +4,17 @@
import sys
import os
import json
from pathlib import Path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from renamer.extractors.filename_extractor import FilenameExtractor
def test_detection():
with open('renamer/test/test_cases.json', 'r') as f:
test_cases = json.load(f)
# Load test cases from new dataset location
dataset_file = Path(__file__).parent / "datasets" / "filenames" / "filename_patterns.json"
with open(dataset_file, 'r', encoding='utf-8') as f:
data = json.load(f)
test_cases = data['test_cases']
print("Testing filename metadata detection with assertions...\n")
@@ -35,7 +39,8 @@ def test_detection():
"hdr": extractor.extract_hdr(),
"movie_db": extractor.extract_movie_db(),
"special_info": extractor.extract_special_info(),
"audio_langs": extractor.extract_audio_langs()
"audio_langs": extractor.extract_audio_langs(),
"extension": extractor.extract_extension()
}
# Check each field