85 lines
2.3 KiB
Python
85 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for Episode Matcher components
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Add src to path so we can import our modules
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
|
|
|
from TVDBProvider.tvdb_client import MockTVDBClient
|
|
from Matcher.file_classifier import FileClassifier
|
|
from Matcher.episode_renamer import EpisodeRenamer
|
|
|
|
|
|
def test_tvdb_client():
|
|
"""Test TVDB client functionality."""
|
|
print("=== Testing TVDB Client ===")
|
|
|
|
client = MockTVDBClient()
|
|
success = client.authenticate()
|
|
print(f"Authentication: {'✓' if success else '✗'}")
|
|
|
|
episodes = client.get_episode_durations("Game of Thrones", 1)
|
|
if episodes:
|
|
print(f"✓ Got {len(episodes)} episodes")
|
|
print(f" Sample episode: Episode {episodes[0]['episode_number']} - {episodes[0]['runtime']} min")
|
|
else:
|
|
print("✗ Failed to get episodes")
|
|
|
|
print()
|
|
|
|
|
|
def test_file_classifier():
|
|
"""Test file classifier with current directory (no MKV files expected)."""
|
|
print("=== Testing File Classifier ===")
|
|
|
|
try:
|
|
classifier = FileClassifier(".")
|
|
print(f"✓ Classifier initialized for current directory")
|
|
print(f" Found {len(classifier.video_files)} MKV files")
|
|
|
|
if classifier.video_files:
|
|
episodes, extras = classifier.classify_files()
|
|
print(f" Would classify {len(episodes)} episodes, {len(extras)} extras")
|
|
|
|
except Exception as e:
|
|
print(f"✗ Classifier error: {e}")
|
|
|
|
print()
|
|
|
|
|
|
def test_episode_renamer():
|
|
"""Test episode renamer functionality."""
|
|
print("=== Testing Episode Renamer ===")
|
|
|
|
renamer = EpisodeRenamer(".", "Test Show", 1)
|
|
print(f"✓ Renamer initialized")
|
|
|
|
# Test filename generation
|
|
test_filename = renamer._generate_episode_filename(5, ".mkv")
|
|
expected = "Test Show s01e05.mkv"
|
|
print(f" Filename generation: {'✓' if test_filename == expected else '✗'}")
|
|
print(f" Generated: {test_filename}")
|
|
print(f" Expected: {expected}")
|
|
|
|
print()
|
|
|
|
|
|
def main():
|
|
"""Run all tests."""
|
|
print("Episode Matcher Component Tests\n")
|
|
|
|
test_tvdb_client()
|
|
test_file_classifier()
|
|
test_episode_renamer()
|
|
|
|
print("Tests completed!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|