Пример #1
0
 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"
     ]
Пример #2
0
 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
Пример #4
0
 def test_newhope(self):
     assert get_movie_from_url(["http://swapi.dev/api/films/1/"
                                ]) == ["4. A New Hope"]
Пример #5
0
 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/"
         ])
Пример #6
0
 def test_incorrect_url(self):
     with pytest.raises(SystemExit):
         assert get_movie_from_url(["http://swapi.dev/api/films/7/"])
Пример #7
0
 def test_empty_set_results(self):
     with pytest.raises(SystemExit):
         assert get_movie_from_url([])
Пример #8
0
 def test_revengesith(self):
     assert get_movie_from_url(["http://swapi.dev/api/films/6/"
                                ]) == ["3. Revenge of the Sith"]
Пример #9
0
 def test_attackclones(self):
     assert get_movie_from_url(["http://swapi.dev/api/films/5/"
                                ]) == ["2. Attack of the Clones"]
Пример #10
0
 def test_phantomenace(self):
     assert get_movie_from_url(["http://swapi.dev/api/films/4/"
                                ]) == ["1. The Phantom Menace"]
Пример #11
0
 def test_returnjedi(self):
     assert get_movie_from_url(["http://swapi.dev/api/films/3/"
                                ]) == ["6. Return of the Jedi"]
Пример #12
0
 def test_empirestrikesback(self):
     assert get_movie_from_url(["http://swapi.dev/api/films/2/"
                                ]) == ["5. The Empire Strikes Back"]