This commit is contained in:
team3
2026-09-18 23:47:25 +02:00
parent db77c1f985
commit a90044b0a7
21 changed files with 1111 additions and 253 deletions

View File

@@ -0,0 +1,20 @@
"""Ob ein Film leihbar ist, kommt aus den Anbieterdaten von TMDB."""
from app import db, tmdb
def test_leihbar_aus_anbieterdaten():
de = lambda eintrag: {"watch/providers": {"results": {"DE": eintrag}}}
assert tmdb.pick_rentable(de({"rent": [{"provider_name": "Amazon Video"}]})) == 1
assert tmdb.pick_rentable(de({"flatrate": [{"provider_name": "Netflix"}]})) == 0
assert tmdb.pick_rentable({"watch/providers": {"results": {}}}) == 0
# Ohne Anbieterdaten bleibt es offen — nicht fälschlich "nicht leihbar"
assert tmdb.pick_rentable({}) is None
def test_leihbarkeit_kommt_mit_dem_film(client):
with db.connect() as conn:
db.upsert(conn, {"id": 7, "title": "Abo-Film", "rentable": 0})
db.upsert(conn, {"id": 8, "title": "Unbekannt"})
assert client.get("/api/movies/7").json()["rentable"] == 0
assert client.get("/api/movies/8").json()["rentable"] is None