""" Regression tests for lower-third source selection. """ import os import sys # Add backend to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from lower_third_source_selection import choose_lower_third_sources def test_choose_lower_third_sources_includes_requested_documentary_buckets(): media_items = { "org-accomp": { "title": "Organizational Accomplishments—Bible Translation Milestones", "_category": "Series", "_subcategory": "Organizational Accomplishments", "firstPublished": "2022-09-01", }, "truth": { "title": "Katri Haarla: I Found What I Was Looking For", "_category": "Interviews and Experiences", "_subcategory": "Truth Transforms Lives", "firstPublished": "2024-01-01", }, "bcl": { "title": "Domenic Alessia: Finding Hope Despite Mental Illness", "_category": "Series", "_subcategory": "The Bible Changes Lives", "firstPublished": "2024-01-01", }, "where-now": { "title": "Where Are They Now? Francis Paez del Rosario: We Found Something Better", "_category": "Series", "_subcategory": "Where Are They Now?", "firstPublished": "2023-01-01", }, "generic-interview": { "title": "A Visit to the Branch", "_category": "Interviews and Experiences", "_subcategory": "From Our Archives", "firstPublished": "2020-01-01", }, "audio-description": { "title": "Organizational Accomplishments—Bible Translation Milestones (With Audio Descriptions)", "_category": "Audio Descriptions", "_subcategory": "Organizational Accomplishments", "firstPublished": "2022-09-01", }, } candidates = choose_lower_third_sources(media_items) assert [(item.natural_key, item.source_bucket) for item in candidates] == [ ("bcl", "bible_changes_lives"), ("generic-interview", "interviews_and_experiences"), ("org-accomp", "organizational_accomplishments"), ("truth", "truth_transforms_lives"), ("where-now", "where_are_they_now"), ]