def setUpClass(cls): global redis_graph cls.r = redis() cls.r.start() redis_con = cls.r.client() redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph)
def setUpClass(cls): global redis_graph cls.r = redis() cls.r.start() redis_con = cls.r.client() redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph)
def main(argv): global redis_con global redis_graph if "--debug" in argv: debug() else: with _redis() as redis_con: redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph) run_queries()
def debug(host, port): global redis_con global redis_graph redis_con = redis.Redis(host=host, port=port) redis_graph = Graph(imdb_utils.graph_name, redis_con) print("populate_graph") imdb_utils.populate_graph(redis_con, redis_graph) print("run_queries") run_queries()
def debug(): print("debug") global redis_con global redis_graph redis_con = redis.Redis(host='localhost', port=6379) redis_graph = Graph(imdb_utils.graph_name, redis_con) print("populate_graph") imdb_utils.populate_graph(redis_con, redis_graph) print("run_queries") run_queries()
def test_find_ten_oldest_actors(self): with self.redis() as redis_con: redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph) actual_result = redis_graph.query( queries.find_ten_oldest_actors_query.query) # assert result set self._assert_only_expected_resuls_are_in_actual_results( actual_result, queries.find_ten_oldest_actors_query) # assert query run time self._assert_run_time(actual_result, queries.find_ten_oldest_actors_query)
def test_actors_played_in_bad_drama_or_comedy(self): with self.redis() as redis_con: redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph) actual_result = redis_graph.query( queries.actors_played_in_bad_drama_or_comedy_query.query) # assert result set self._assert_only_expected_resuls_are_in_actual_results( actual_result, queries.actors_played_in_bad_drama_or_comedy_query) # assert query run time self._assert_run_time( actual_result, queries.actors_played_in_bad_drama_or_comedy_query)
def test_actors_over_50_that_played_in_blockbusters(self): with self.redis() as redis_con: redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph) actual_result = redis_graph.query( queries.actors_over_50_that_played_in_blockbusters_query.query) # assert result set self._assert_only_expected_resuls_are_in_actual_results( actual_result, queries.actors_over_50_that_played_in_blockbusters_query) # assert query run time self._assert_run_time( actual_result, queries.actors_over_50_that_played_in_blockbusters_query)
def test_how_many_movies_cameron_diaz_played(self): with self.redis() as redis_con: redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph) actual_result = redis_graph.query( queries.how_many_movies_cameron_diaz_played_query.query) # assert result set self._assert_only_expected_resuls_are_in_actual_results( actual_result, queries.how_many_movies_cameron_diaz_played_query) # assert query run time self._assert_run_time( actual_result, queries.how_many_movies_cameron_diaz_played_query)
def test_sum_and_average_age_of_straight_outta_compton_cast(self): with self.redis() as redis_con: redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph) actual_result = redis_graph.query( queries. sum_and_average_age_of_straight_outta_compton_cast_query.query) # assert result set self._assert_only_expected_resuls_are_in_actual_results( actual_result, queries. sum_and_average_age_of_straight_outta_compton_cast_query) # assert query run time self._assert_run_time( actual_result, queries. sum_and_average_age_of_straight_outta_compton_cast_query)
def __init__(self): super(testImdbFlow, self).__init__() global redis_graph global queries redis_con = self.env.getConnection() redis_graph = Graph(imdb_utils.graph_name, redis_con) actors, movies = imdb_utils.populate_graph(redis_con, redis_graph) queries = imdb_queries.IMDBQueries(actors, movies)
def setUp(self): global imdb global queries global redis_graph redis_con = self.env.getConnection() redis_graph = Graph(imdb_utils.graph_name, redis_con) actors, movies = imdb_utils.populate_graph(redis_con, redis_graph) imdb = imdb_queries.IMDBQueries(actors, movies) queries = imdb.queries()
def test_actors_played_with_cameron_diaz_and_younger_than_her(self): with self.redis() as redis_con: redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph) actual_result = redis_graph.query( queries. actors_played_with_cameron_diaz_and_younger_than_her_query. query) # assert result set self._assert_only_expected_resuls_are_in_actual_results( actual_result, queries. actors_played_with_cameron_diaz_and_younger_than_her_query) # assert query run time self._assert_run_time( actual_result, queries. actors_played_with_cameron_diaz_and_younger_than_her_query)
def main(argv): global redis_con global redis_graph parser = argparse.ArgumentParser(description='Social demo.', add_help=False) parser.add_argument('-h', '--host', dest='host', help='redis host') parser.add_argument('-p', '--port', dest='port', type=int, help='redis port') parser.add_argument("--debug", action='store_const', const=True) args = parser.parse_args() if args.debug is not None: debug('127.0.0.1', 6379) elif args.host is not None and args.port is not None: debug(args.host, args.port) else: with _redis() as redis_con: redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph) run_queries()
def setUpClass(cls): print "ImdbFlowTest" global redis_graph global queries cls.r = redis() cls.r.start() redis_con = cls.r.client() redis_graph = Graph(imdb_utils.graph_name, redis_con) actors, movies = imdb_utils.populate_graph(redis_con, redis_graph) queries = imdb_queries.IMDBQueries(actors, movies)
def test_find_three_actors_played_with_nicolas_cage(self): NUM_EXPECTED_RESULTS = 3 with self.redis() as redis_con: redis_graph = Graph(imdb_utils.graph_name, redis_con) imdb_utils.populate_graph(redis_con, redis_graph) actual_result = redis_graph.query( queries.find_three_actors_played_with_nicolas_cage_query.query) # assert result set self._assert_actual_results_contained_in_expected_results( actual_result, queries.find_three_actors_played_with_nicolas_cage_query, NUM_EXPECTED_RESULTS) # assert query run time self._assert_run_time( actual_result, queries.find_three_actors_played_with_nicolas_cage_query)