示例#1
0
 def test_movie_tomato_plot(self):
     self.assertEqual(Movie("Forrest Gump").plot,
                      "Forrest Gump is a simple man with a low I.Q. but good intentions. "
                      "He is running through childhood with his best and only friend Jenny. "
                      "His 'mama' teaches him the ways of life and leaves him to choose his destiny. "
                      "Forrest joins the army for service in Vietnam, finding new friends called Dan "
                      "and Bubba, he wins medals, creates a famous shrimp fishing fleet, inspires people "
                      "to jog, starts a ping-pong craze, creates the smiley, writes bumper stickers and songs, "
                      "donates to people and meets the president several times. However, this is all "
                      "irrelevant to Forrest who can only think of his childhood sweetheart Jenny Curran, "
                      "who has messed up her life. Although in the end all he wants to prove is that "
                      "anyone can love anyone.")
示例#2
0
def run():
    """The main routine."""
    parser = argparse.ArgumentParser(
        description=
        "This python scripts retrieves the rating of a movie given its title."
        "\n\tExample: \n\t>> watch-movie 'lord of the rings' 2003")
    parser.add_argument("name",
                        help="The name of movie you want to search",
                        type=str)
    parser.add_argument("release_year",
                        help='The release year of the movie.',
                        type=int,
                        nargs='?',
                        default=0)
    parser.add_argument("-e",
                        "--exact_match",
                        help="search exact name of the movie.",
                        action="store_true")

    args = parser.parse_args()

    try:
        movie = Movie(name=args.name,
                      exact_match=args.exact_match,
                      year=args.release_year)
        print(u"{} ({})".format(movie.title, movie.year))
        print(u"Awards: {}".format(movie.awards))
        print(u"IMDB Rating: {}/10".format(movie.imdb_rating))
        print(u"Tomato Meter: {}/100".format(movie.tomatometer))
        print(u"Meta Score: {}/100".format(movie.metascore))
        print(u"Director: {}".format(", ".join(movie.directors)))
        print(u"Cast: {}".format(", ".join(movie.cast)))
        print(u"Genre: {}".format(", ".join(movie.genre)))
        print(u"Country: {}".format(", ".join(movie.country)))
        print(u"Writer: {}".format(", ".join(movie.writers)))
        print(u"Language: {}".format(", ".join(movie.language)))
        print(u"Runtime: {}".format(movie.runtime))
        print(u"Released: {}".format(movie.released))
        print(u"Rated: {}".format(movie.rated))
        print(u"IMDB ID: {}".format(movie.imdb_id))
        print(u"Plot: {}".format(movie.plot))
    except MovieNotFound:
        print("No movie found!")
    except ConnectionError:
        print("No response!")
示例#3
0
 def test_movie_name_4(self):
     self.assertEqual(Movie('hello', exact_match=True).title, 'Hello')
示例#4
0
 def test_meta_score(self):
     self.assertEqual(Movie('shawshank redemption').metascore, 80)
示例#5
0
 def test_movie_name(self):
     self.assertEqual(Movie('the matrix revolutions').title, 'The Matrix Revolutions')
示例#6
0
 def test_unicode_actor(self):
     self.assertEqual(", ".join(Movie('like love kiarostami').cast), u'Tadashi Okuno, Rin Takanashi, Ryô Kase, Denden')
示例#7
0
 def test_fallback_to_google_2(self):
     self.assertEqual(Movie('like love kiarostami').title, 'Like Someone in Love')
示例#8
0
 def test_movie_writers2(self):
     self.assertEqual(", ".join(Movie("test").writers), u'Nicholas Gyeney (story), Nicholas Gyeney, André Kirkman')
示例#9
0
 def test_imdb_rating_5(self):
     self.assertEqual(Movie("The Lord of the Rings", exact_match=False, year=2003).imdb_rating, 8.9)
示例#10
0
 def test_imdb_rating_2(self):
     self.assertEqual(Movie('redemption').imdb_rating, 9.3)
示例#11
0
 def test_imdb_rating_1(self):
     self.assertEqual(Movie('shawshank redemption').imdb_rating, 9.3)
示例#12
0
 def test_movie_director(self):
     self.assertEqual(", ".join(Movie('A Separation').directors), 'Asghar Farhadi')
示例#13
0
 def test_repr(self):
     self.assertEqual(repr(Movie('godfather', year=1972)), "Movie(The Godfather - 1972)")
示例#14
0
 def test_str(self):
     self.assertEqual(str(Movie('godfather', year=1972)), "The Godfather (1972)")
示例#15
0
 def test_movie_tomato_meter(self):
     self.assertAlmostEquals(Movie("star wars", exact_match=False, year=1980).tomatometer, 0, delta=4)
示例#16
0
 def test_movie_language(self):
     self.assertEqual(", ".join(Movie("pulp fiction").language), 'English, Spanish, French')
示例#17
0
 def test_movie_writers(self):
     self.assertEqual(", ".join(Movie("fight club").writers), 'Chuck Palahniuk (novel), Jim Uhls (screenplay)')
示例#18
0
 def test_imdb_rating_6(self):
     self.assertEqual(Movie("The Lord of the Rings", exact_match=False, year=1978).imdb_rating, 6.2)
示例#19
0
 def test_movie_tomato_meter(self):
     self.assertEqual(Movie("star wars", exact_match=False, year=1980).tomatometer, 94)
示例#20
0
 def test_movie_year(self):
     self.assertEqual(Movie('sixth sense').year, 1999)
示例#21
0
 def test_fallback_to_google_1(self):
     self.assertEqual(Movie('forushande').title, 'The Salesman')
示例#22
0
 def test_movie_cast(self):
     self.assertEqual(", ".join(Movie('matrix').cast),
                      "Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, Hugo Weaving")
示例#23
0
 def test_fallback_to_google_3(self):
     self.assertEqual(", ".join(Movie('so far so near mirkarimi').writers), 'Mohammad Reza Gohari, Reza Mirkarimi')
示例#24
0
 def test_movie_imdb_id(self):
     self.assertEqual(Movie('match point').imdb_id, 'tt0416320')
示例#25
0
 def test_release(self):
     self.assertEqual(Movie('godfather', year=1972).released, datetime.date(1972, 3, 24))
示例#26
0
 def test_movie_genre(self):
     self.assertEqual(", ".join(Movie('godfather').genre), 'Crime, Drama')
示例#27
0
 def test_runtime(self):
     self.assertEqual(Movie('godfather', year=1990).runtime, 162)
示例#28
0
 def test_movie_awards(self):
     self.assertEqual(Movie('12 Angry Men').awards, 'Nominated for 3 Oscars. Another 16 wins & 8 nominations.')
示例#29
0
 def test_rated(self):
     self.assertEqual(Movie('fight club').rated, 'R')
示例#30
0
 def test_movie_country(self):
     self.assertEqual(", ".join(Movie("schindler's list").country), 'USA')