update
This commit is contained in:
20
backend/tests/test_leihbar.py
Normal file
20
backend/tests/test_leihbar.py
Normal 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
|
||||
Reference in New Issue
Block a user