def test_loading_profile_from_file(): filename = path.join(path.dirname(__file__), "..", "resources", "example.ini") prof = ConnectionProfile.from_file(filename, "Neo4j") data = dict(prof) assert data == { 'secure': False, 'verify': True, 'scheme': 'bolt', 'user': '******', 'password': '******', 'address': IPv4Address(('graph.mystery.inc', 7777)), 'auth': ('shaggy', 'velma'), 'host': 'graph.mystery.inc', 'port': 7777, 'port_number': 7777, 'protocol': 'bolt', 'uri': 'bolt://[email protected]:7777', }
) from py2neo import ConnectionProfile from py2neo.ogm import Repository from py2neo.ogm.models.movies import Movie, Person HOME = dirname(__file__) STATIC = path.join(HOME, "static") VIEWS = path.join(HOME, "views") CONFIG = path.join(HOME, "movies.ini") # Update the template search path used by Bottle TEMPLATE_PATH.append(VIEWS) # Load the connection details from the config file profile = ConnectionProfile.from_file(CONFIG, "Neo4j") # Set up a link to the local graph database. repo = Repository(profile) if repo.match(Movie).count() == 0: print("No movie data found in repository %r" % repo) answer = input( "Would you like to automatically load the Neo4j movies data set [y/N]? " ) if answer and answer[0].upper() == "Y": with open(path.join(HOME, "data", "movies.cypher")) as fin: query = fin.read() repo.graph.run(query) print("Movie data loaded - %d movies available" % repo.match(Movie).count())