soulsync/tests/test_video_followed_shows.py
BoulderBadgeDad 66bce2b83a Watchlist hygiene: auto-prune ended/canceled followed shows
You can eye-add a show to the watchlist before we know its status, so ended/canceled
shows leak in (auto-airing LIBRARY shows already exclude ended ones; explicit follows
don't). Fix it as cleanup-on-process, per Boulder: the daily 'Wishlist Today's Airings'
automation now runs a watchlist-tidy pass first — scans every explicit show follow,
resolves its status (local for owned, TMDB for tmdb-only follows), and removes any
that have ended/been canceled/completed. Only prunes on a DEFINITIVE terminal status;
unknown/lookup-error → left alone. Toggle prune_ended (default on); returns shows_pruned.

DB: followed_shows(). Pure prune_ended_show_follows() with injected seams; seam tests.
2026-06-21 15:05:20 -07:00

35 lines
1.3 KiB
Python

"""followed_shows(): explicit show follows + their library status — feeds the
watchlist-prune pass that drops ended/canceled shows."""
from __future__ import annotations
import pytest
from database.video_database import VideoDatabase
@pytest.fixture()
def db(tmp_path):
return VideoDatabase(database_path=str(tmp_path / "video_library.db"))
def test_lists_explicit_follows_with_library_status(db):
# a tmdb-only follow (no library row → status None)
db.add_to_watchlist("show", 100, "TMDB Only")
# a follow backed by a library show carrying a status
conn = db._get_connection()
conn.execute("INSERT INTO shows (id, server_source, title, tmdb_id, status) "
"VALUES (5, 'plex', 'Owned Show', 200, 'Ended')")
conn.commit(); conn.close()
db.add_to_watchlist("show", 200, "Owned Show", library_id=5)
rows = {r["tmdb_id"]: r for r in db.followed_shows()}
assert rows[100]["status"] is None # tmdb-only → no local status
assert rows[200]["status"] == "Ended" # owned → carries the status
def test_excludes_muted_and_people(db):
db.add_to_watchlist("show", 1, "A")
db.remove_from_watchlist("show", 1) # mute (tombstone)
db.add_to_watchlist("person", 2, "Someone")
assert db.followed_shows() == [] # neither muted shows nor people