def graph_db(localhost): from polyglotdb.client.client import PGDBClient, ClientError client = PGDBClient(localhost) dbs = client.list_databases() for d in dbs: if 'test' in d: client.delete_database(d) client.create_database('main_test_database') ports = client.get_ports('main_test_database') ports['data_dir'] = client.get_directory('main_test_database') ports['host'] = 'localhost' client.start_database('main_test_database') return ports
def graph_db(localhost, auth_token): from polyglotdb.client.client import PGDBClient, ClientError client = PGDBClient(localhost, token=auth_token) dbs = client.list_databases() print(dbs) for d in dbs: if d['name'] == 'main_test_database': client.delete_database(d['name']) client.create_database('main_test_database') ports = client.get_ports('main_test_database') ports['data_dir'] = client.get_directory('main_test_database') ports['host'] = 'localhost' client.start_database('main_test_database') return ports
def test_client_create_database(graph_db, localhost, auth_token): print(graph_db) client = PGDBClient(localhost, token=auth_token) try: client.delete_database('test_database') except ClientError: pass with pytest.raises(ClientError): client.delete_database('test_database') client.create_database('test_database') with pytest.raises(ClientError): response = client.create_database('test_database') ports = client.get_ports('test_database') assert 'graph_http_port' in ports assert 'graph_bolt_port' in ports assert 'acoustic_http_port' in ports