def test_sortedmovies(self): assert get_movie_from_url([ "http://swapi.dev/api/films/1/", "http://swapi.dev/api/films/2/", "http://swapi.dev/api/films/3/", "http://swapi.dev/api/films/4/", "http://swapi.dev/api/films/5/", "http://swapi.dev/api/films/6/" ]) == [ "1. The Phantom Menace", "2. Attack of the Clones", "3. Revenge of the Sith", "4. A New Hope", "5. The Empire Strikes Back", "6. Return of the Jedi" ]
def test_longerthansix(self): with pytest.raises(SystemExit): assert get_movie_from_url([ "http://swapi.dev/api/films/1/", "http://swapi.dev/api/films/2/", "http://swapi.dev/api/films/3/", "http://swapi.dev/api/films/4/", "http://swapi.dev/api/films/5/", "http://swapi.dev/api/films/6/", "http://swapi.dev/api/films/6/" ])
def lambda_swapi_func(first_char: str, second_char: str) -> Union[str, List]: """ Takes the inputted characters and returns a message indicating whether they were found on SWAPI, if there are movies where both characters appear, and the movies titles if there were matches. """ link_list = get_swapi_matches(first_char, second_char) set_results = get_common_movies(link_list) if type(set_results) != list: return set_results else: cleaned_results = get_movie_from_url(set_results) print("\n|RESULT| -> The selected characters share these movies:") return cleaned_results
def test_newhope(self): assert get_movie_from_url(["http://swapi.dev/api/films/1/" ]) == ["4. A New Hope"]
def test_duplicate_url(self): with pytest.raises(SystemExit): assert get_movie_from_url([ "http://swapi.dev/api/films/1/", "http://swapi.dev/api/films/1/" ])
def test_incorrect_url(self): with pytest.raises(SystemExit): assert get_movie_from_url(["http://swapi.dev/api/films/7/"])
def test_empty_set_results(self): with pytest.raises(SystemExit): assert get_movie_from_url([])
def test_revengesith(self): assert get_movie_from_url(["http://swapi.dev/api/films/6/" ]) == ["3. Revenge of the Sith"]
def test_attackclones(self): assert get_movie_from_url(["http://swapi.dev/api/films/5/" ]) == ["2. Attack of the Clones"]
def test_phantomenace(self): assert get_movie_from_url(["http://swapi.dev/api/films/4/" ]) == ["1. The Phantom Menace"]
def test_returnjedi(self): assert get_movie_from_url(["http://swapi.dev/api/films/3/" ]) == ["6. Return of the Jedi"]
def test_empirestrikesback(self): assert get_movie_from_url(["http://swapi.dev/api/films/2/" ]) == ["5. The Empire Strikes Back"]