def test_omdb_search__media_type_invalid(omdb_api_key): with pytest.raises(MapiProviderException): omdb_search(omdb_api_key, "ninja turtles", media_type="hologram")
def test_omdb_search__page_diff(omdb_api_key): p1 = omdb_search(omdb_api_key, "Dogs", page=1) p2 = omdb_search(omdb_api_key, "Dogs", page=2) assert p1 != p2
def test_omdb_search__page_out_of_bounds(omdb_api_key): with pytest.raises(MapiNotFoundException): omdb_search(omdb_api_key, "Super Mario", page=100)
def test_omdb_search__query__fail(omdb_api_key): with pytest.raises(MapiNotFoundException): omdb_search(omdb_api_key, JUNK_TEXT, cache=False)
def test_omdb_search__year(omdb_api_key): result = omdb_search(omdb_api_key, "ninja turtles", year=1987) assert "tt0131613" == result["Search"][0]["imdbID"]
def test_omdb_search__api_key_fail(): with pytest.raises(MapiProviderException): omdb_search(JUNK_TEXT, "ninja turtles", cache=False)
def test_omdb_search__query__series(omdb_api_key): result = omdb_search(omdb_api_key, "ninja turtles", media_type="series") assert all([entry["Type"] == "series" for entry in result["Search"]])
def test_omdb_search__query__mixed_media(media_type, omdb_api_key): result = omdb_search(omdb_api_key, "ninja turtles") assert not any([entry["Type"] == "song" for entry in result["Search"]])
def test_omdb_search__fields__search(omdb_api_key): expected_fields = {"Title", "Year", "imdbID", "Type", "Poster"} result = omdb_search(omdb_api_key, "ninja turtles")["Search"][0] assert set(result.keys()) == expected_fields
def test_omdb_search__fields__top_level(omdb_api_key): expected_fields = {"Search", "Response", "totalResults"} result = omdb_search(omdb_api_key, "ninja turtles") assert set(result.keys()) == expected_fields