Test to search for a movie on crud

This commit is contained in:
Colin Goutte 2023-08-27 21:04:52 +02:00
parent d25a8c66e1
commit 1565863b56
1 changed files with 30 additions and 0 deletions

View File

@ -122,6 +122,36 @@ def test_list_movies():
assert all(movies_by_title[name] for name in names)
def test_search_movies():
clear_db()
response = client.get("/movies/")
# assert response.json() == []
radix = rand_name()
name = radix + "test_search"
desc = radix + "test_desription"
with db_context() as db:
movie_name = crud.create_movie(
db, title=name, genres=["Animated", "Paropaganda"]
)
movie_desc = crud.create_movie(
db, title=radix, description=desc, genres=["Animated", "Paropaganda"]
)
for term, target in zip((name, desc), (movie_name, movie_desc)):
with db_context() as db:
found = crud.search_movie(db, desc).all()
assert len(found) == 1
assert target == found[0]
movies = client.get("movies").json()["movies"]
movies_by_title = {m["title"]: m for m in movies}
assert all(movies_by_title[name] for name in names)
def test_sample_import_toy_story():
clear_db()