Add unit tests for Python matching script #14

Closed
opened 2026-01-17 18:12:26 +00:00 by joezombie · 1 comment
joezombie commented 2026-01-17 18:12:26 +00:00 (Migrated from github.com)

Priority

Low

Description

Create comprehensive unit tests for the Python fuzzy matching script to ensure correctness and prevent regressions.

Files to Create

  • test_match_episodes.py

Test Coverage Needed

  1. Fuzzy matching algorithm
  2. Part number extraction
  3. Title normalization
  4. Similarity scoring
  5. File path handling
  6. Error handling paths

Example Tests

import unittest
from match_episodes import (
    normalize_title, 
    extract_part_number,
    similarity_score
)

class TestFuzzyMatching(unittest.TestCase):
    def test_normalize_title(self):
        title = "Episode Name | BEHIND THE BASTARDS"
        expected = "Episode Name"
        self.assertEqual(normalize_title(title), expected)
    
    def test_extract_part_number(self):
        self.assertEqual(extract_part_number("Part One: Title"), 1)
        self.assertEqual(extract_part_number("Part Two: Title"), 2)
        self.assertEqual(extract_part_number("Pt 3: Title"), 3)
        self.assertIsNone(extract_part_number("No Part"))
    
    def test_similarity_score(self):
        score = similarity_score("Episode Name", "Episode Name")
        self.assertGreater(score, 0.9)

Benefits

  • Prevents regressions
  • Validates algorithm correctness
  • Easier refactoring
  • Documentation of expected behavior

References

  • CODE_REVIEW.md: Testing section
  • RECOMMENDATIONS.md: Priority 4, Item 1

Estimate

2 hours

## Priority Low ## Description Create comprehensive unit tests for the Python fuzzy matching script to ensure correctness and prevent regressions. ## Files to Create - `test_match_episodes.py` ## Test Coverage Needed 1. Fuzzy matching algorithm 2. Part number extraction 3. Title normalization 4. Similarity scoring 5. File path handling 6. Error handling paths ## Example Tests ```python import unittest from match_episodes import ( normalize_title, extract_part_number, similarity_score ) class TestFuzzyMatching(unittest.TestCase): def test_normalize_title(self): title = "Episode Name | BEHIND THE BASTARDS" expected = "Episode Name" self.assertEqual(normalize_title(title), expected) def test_extract_part_number(self): self.assertEqual(extract_part_number("Part One: Title"), 1) self.assertEqual(extract_part_number("Part Two: Title"), 2) self.assertEqual(extract_part_number("Pt 3: Title"), 3) self.assertIsNone(extract_part_number("No Part")) def test_similarity_score(self): score = similarity_score("Episode Name", "Episode Name") self.assertGreater(score, 0.9) ``` ## Benefits - Prevents regressions - Validates algorithm correctness - Easier refactoring - Documentation of expected behavior ## References - CODE_REVIEW.md: Testing section - RECOMMENDATIONS.md: Priority 4, Item 1 ## Estimate 2 hours
joezombie commented 2026-01-17 20:23:06 +00:00 (Migrated from github.com)

Resolved in merged PR

Resolved in merged PR
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
joezombie/castr#14
No description provided.