Example #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.")
Example #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!")
Example #3
0
 def test_movie_name_4(self):
     self.assertEqual(Movie('hello', exact_match=True).title, 'Hello')
Example #4
0
 def test_meta_score(self):
     self.assertEqual(Movie('shawshank redemption').metascore, 80)
Example #5
0
 def test_movie_name(self):
     self.assertEqual(Movie('the matrix revolutions').title, 'The Matrix Revolutions')
Example #6
0
 def test_unicode_actor(self):
     self.assertEqual(", ".join(Movie('like love kiarostami').cast), u'Tadashi Okuno, Rin Takanashi, Ryô Kase, Denden')
Example #7
0
 def test_fallback_to_google_2(self):
     self.assertEqual(Movie('like love kiarostami').title, 'Like Someone in Love')
Example #8
0
 def test_movie_writers2(self):
     self.assertEqual(", ".join(Movie("test").writers), u'Nicholas Gyeney (story), Nicholas Gyeney, André Kirkman')
Example #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)
Example #10
0
 def test_imdb_rating_2(self):
     self.assertEqual(Movie('redemption').imdb_rating, 9.3)
Example #11
0
 def test_imdb_rating_1(self):
     self.assertEqual(Movie('shawshank redemption').imdb_rating, 9.3)
Example #12
0
 def test_movie_director(self):
     self.assertEqual(", ".join(Movie('A Separation').directors), 'Asghar Farhadi')
Example #13
0
 def test_repr(self):
     self.assertEqual(repr(Movie('godfather', year=1972)), "Movie(The Godfather - 1972)")
Example #14
0
 def test_str(self):
     self.assertEqual(str(Movie('godfather', year=1972)), "The Godfather (1972)")
Example #15
0
 def test_movie_tomato_meter(self):
     self.assertAlmostEquals(Movie("star wars", exact_match=False, year=1980).tomatometer, 0, delta=4)
Example #16
0
 def test_movie_language(self):
     self.assertEqual(", ".join(Movie("pulp fiction").language), 'English, Spanish, French')
Example #17
0
 def test_movie_writers(self):
     self.assertEqual(", ".join(Movie("fight club").writers), 'Chuck Palahniuk (novel), Jim Uhls (screenplay)')
Example #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)
Example #19
0
 def test_movie_tomato_meter(self):
     self.assertEqual(Movie("star wars", exact_match=False, year=1980).tomatometer, 94)
Example #20
0
 def test_movie_year(self):
     self.assertEqual(Movie('sixth sense').year, 1999)
Example #21
0
 def test_fallback_to_google_1(self):
     self.assertEqual(Movie('forushande').title, 'The Salesman')
Example #22
0
 def test_movie_cast(self):
     self.assertEqual(", ".join(Movie('matrix').cast),
                      "Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, Hugo Weaving")
Example #23
0
 def test_fallback_to_google_3(self):
     self.assertEqual(", ".join(Movie('so far so near mirkarimi').writers), 'Mohammad Reza Gohari, Reza Mirkarimi')
Example #24
0
 def test_movie_imdb_id(self):
     self.assertEqual(Movie('match point').imdb_id, 'tt0416320')
Example #25
0
 def test_release(self):
     self.assertEqual(Movie('godfather', year=1972).released, datetime.date(1972, 3, 24))
Example #26
0
 def test_movie_genre(self):
     self.assertEqual(", ".join(Movie('godfather').genre), 'Crime, Drama')
Example #27
0
 def test_runtime(self):
     self.assertEqual(Movie('godfather', year=1990).runtime, 162)
Example #28
0
 def test_movie_awards(self):
     self.assertEqual(Movie('12 Angry Men').awards, 'Nominated for 3 Oscars. Another 16 wins & 8 nominations.')
Example #29
0
 def test_rated(self):
     self.assertEqual(Movie('fight club').rated, 'R')
Example #30
0
 def test_movie_country(self):
     self.assertEqual(", ".join(Movie("schindler's list").country), 'USA')