def test_add_edge_to_graph(self):
        graph = Graph()

        graph.add_edge("Ann Hathaway", "Princess Diaries", 100)
        self.assertEqual(len(graph.edges), 1)
        self.assertEqual(graph.edges[0].movie, "Princess Diaries")
        self.assertEqual(graph.edges[0].actor, "Ann Hathaway")
        self.assertEqual(graph.edges[0].weight, 100)
示例#2
0
 def testGraphAddEdge(self):
     """
     Tests adding an edge
     """
     graph = Graph()
     graph.parseFile(TESTFILE)
     tmp_movie = Movies("BlahBlah", "1980", "$121,890,708",
                        "Robert Redford")
     tmp_actor = Actors("Freeman Blah", 80, "BlahBlah")
     graph.add_movie(tmp_movie)
     graph.add_actor(tmp_actor)
     graph.add_edge(Edges(tmp_actor.name, tmp_movie.name, 222759050.0))
示例#3
0
 def testMovieActors(self):
     """
     Tests finding actors who acted in a given movie
     """
     graph = Graph()
     graph.parseFile(TESTFILE)
     tmp_movie = Movies("BlahBlah", "1980", "$121,890,708",
                        "Robert Redford")
     tmp_actor = Actors("Freeman Blah", 80, "BlahBlah")
     graph.add_movie(tmp_movie)
     graph.add_actor(tmp_actor)
     graph.add_edge(Edges(tmp_actor.name, tmp_movie.name, 222759050.0))
     graph.get_actors_for_movie("The Arrangement")
示例#4
0
 def testMovieGross(self):
     """
     Tests how much a movie grossed at Box Office
     """
     graph = Graph()
     graph.parseFile(TESTFILE)
     tmp_movie = Movies("BlahBlah", "1980", "$121,890,708",
                        "Robert Redford")
     tmp_actor = Actors("Freeman Blah", 80, "BlahBlah")
     graph.add_movie(tmp_movie)
     graph.add_actor(tmp_actor)
     graph.add_edge(Edges(tmp_actor.name, tmp_movie.name, 222759050.0))
     graph.get_movie_gross("The Thomas Crown Affair")
示例#5
0
 def testGetMoviesForYear(self):
     """
     Tests getting movies for given year
     """
     graph = Graph()
     graph.parseFile(TESTFILE)
     tmp_movie = Movies("BlahBlah", "1980", "$121,890,708",
                        "Robert Redford")
     tmp_actor = Actors("Freeman Blah", 80, "BlahBlah")
     graph.add_movie(tmp_movie)
     graph.add_actor(tmp_actor)
     graph.add_edge(Edges(tmp_actor.name, tmp_movie.name, 222759050.0))
     graph.get_movies_for_year("1980")
示例#6
0
 def testOldestActors(self):
     """
     Tests finding oldest X actors
     """
     graph = Graph()
     graph.parseFile(TESTFILE)
     tmp_movie = Movies("BlahBlah", "1980", "$121,890,708",
                        "Robert Redford")
     tmp_actor = Actors("Freeman Blah", 78, "BlahBlah")
     graph.add_movie(tmp_movie)
     graph.add_actor(tmp_actor)
     graph.add_edge(Edges(tmp_actor.name, tmp_movie.name, 222759050.0))
     graph.find_oldest_actors(2)
示例#7
0
 def testHighestGrossing(self):
     """
     Tests finding highest grossing X actors
     """
     graph = Graph()
     graph.parseFile(TESTFILE)
     tmp_movie = Movies("BlahBlah", "1980", "$121,890,708",
                        "Robert Redford")
     tmp_actor = Actors("Freeman Blah", 80, "BlahBlah")
     graph.add_movie(tmp_movie)
     graph.add_actor(tmp_actor)
     graph.add_edge(Edges(tmp_actor.name, tmp_movie.name, 222759050.0))
     graph.find_highest_grossing_actors(5)
    def test_query_2(self):
        graph = Graph()

        edges = []
        edge = graph.add_edge("Ann Hathaway", "Princess Diaries", 100)
        edges.append(edge)
        graph.add_node("Movie", "Princess Diaries", edges, 2019)

        self.assertEqual(len(graph.edges), 1)
        self.assertEqual(graph.edges[0].weight, 100)
        self.assertEqual(graph.get_movie_gross("Princess Diaries"), 100)
    def test_query_3(self):
        graph = Graph()

        edges = []
        edge = graph.add_edge("Ann Hathaway", "Princess Diaries", 100)
        edges.append(edge)
        graph.add_node("Movie", "Princess Diaries", edges, 2019)

        self.assertEqual(
            len(graph.get_list_of_movies_from_actor("Ann Hathaway")), 1)
        self.assertEqual(
            graph.get_list_of_movies_from_actor("Ann Hathaway")[0],
            "Princess Diaries")
示例#10
0
        """
        Tests finding oldest X actors
        """
        graph = Graph()
        graph.parseFile(TESTFILE)
        tmp_movie = Movies("BlahBlah", "1980", "$121,890,708",
                           "Robert Redford")
        tmp_actor = Actors("Freeman Blah", 78, "BlahBlah")
        graph.add_movie(tmp_movie)
        graph.add_actor(tmp_actor)
        graph.add_edge(Edges(tmp_actor.name, tmp_movie.name, 222759050.0))
        graph.find_oldest_actors(2)


if __name__ == "__main__":
    #unittest.main()
    graph = Graph()
    graph.parseFile(TESTFILE)
    tmp_movie = Movies("BlahBlah", "1980", "$121,890,708", "Robert Redford")
    tmp_actor = Actors("Freeman Blah", 78, "BlahBlah")
    graph.add_movie(tmp_movie)
    graph.add_actor(tmp_actor)
    graph.add_edge(Edges(tmp_actor.name, tmp_movie.name, 222759050.0))
    graph.get_movies_for_actor("Faye Dunaway")
    graph.get_movies_for_year("1980")
    graph.get_movie_actors_for_year("1980")
    graph.get_actors_for_movie("The Thomas Crown Affair")
    graph.get_movie_gross("The Thomas Crown Affair")
    graph.find_highest_grossing_actors(5)
    graph.find_oldest_actors(2)