def test_should_generate_base_auth_with_realm_correctly(): auth = basic_auth("molly", "meoooow", "cat_cafe") assert auth.scheme == "basic" assert auth.principal == "molly" assert auth.credentials == "meoooow" assert auth.realm == "cat_cafe" assert not hasattr(auth, "parameters")
from neo4j import GraphDatabase from dotenv import dotenv_values from neo4j.api import basic_auth import os config = dotenv_values('.env') db_host = os.environ.get('NEO4J_HOST', 'localhost') db_port = os.environ.get('NEO4J_PORT', '7687') driver = GraphDatabase.driver(f'bolt://{db_host}:{db_port}', auth=basic_auth('neo4j', os.environ.get('PASS'))) def match_players(tx, player1, player2): # run the actual query to neo4j database, return list format return list(tx.run("match (m:Player {name: $Player1 }), (n:Player {name: $Player2 }), p=shortestPath((m)-[*]-(n)) return p", Player1 = player1, Player2 = player2)) def parse_response(res): # parse the response from the db, get necessary information for i in res: i.pop('_graph'); if ("Player" in i['_labels']): i['_labels'] = "Player" else: i['_labels'] = "Team" labels = i['_labels'] properties = i['_properties'] i.pop('_labels') i.pop('_properties') i['labels'] = labels i['properties'] = properties