def test_to_dict(): p = ConnectionProfile() d = p.to_dict() assert d == { 'address': IPv4Address(('localhost', 7687)), 'host': 'localhost', 'port': 7687, 'port_number': 7687, 'protocol': 'bolt', 'scheme': 'bolt', 'secure': False, 'verify': True, 'uri': 'bolt://neo4j@localhost:7687', 'user': '******', }
def test_bolt_uri_only(): data = dict(ConnectionProfile("bolt://*****:*****@host:9999', 'user': '******', }
def test_https_default_port(): data = dict(ConnectionProfile("https://host")) assert data == { 'address': IPv4Address(('host', 7473)), 'auth': ('neo4j', 'password'), 'host': 'host', 'password': '******', 'port': 7473, 'port_number': 7473, 'protocol': 'http', 'scheme': 'https', 'secure': True, 'verify': True, 'uri': 'https://neo4j@host:7473', 'user': '******', }
def test_explicit_auth_tuple(): data = dict(ConnectionProfile(auth=("bob", "secret"))) assert data == { 'address': IPv4Address(('localhost', 7687)), 'auth': ('bob', 'secret'), 'host': 'localhost', 'password': '******', 'port': 7687, 'port_number': 7687, 'protocol': 'bolt', 'scheme': 'bolt', 'secure': False, 'verify': True, 'uri': 'bolt://bob@localhost:7687', 'user': '******', }
def test_bolt_uri_with_user_and_password(): data = dict(ConnectionProfile("bolt://*****:*****@host:9999")) assert data == { 'address': IPv4Address(('host', 9999)), 'auth': ('bob', 'secret'), 'host': 'host', 'password': '******', 'port': 9999, 'port_number': 9999, 'protocol': 'bolt', 'scheme': 'bolt', 'secure': False, 'verify': True, 'uri': 'bolt://bob@host:9999', 'user': '******', }
def test_secure_and_verify(): data = dict(ConnectionProfile(secure=True, verify=True)) assert data == { 'address': IPv4Address(('localhost', 7687)), 'auth': ('neo4j', 'password'), 'host': 'localhost', 'password': '******', 'port': 7687, 'port_number': 7687, 'protocol': 'bolt', 'scheme': 'bolt+s', 'secure': True, 'verify': True, 'uri': 'bolt+s://neo4j@localhost:7687', 'user': '******', }
def test_https_uri_without_secure(): data = dict(ConnectionProfile("https://*****:*****@host:9999', 'user': '******', }
def test_uri_and_port(): data = dict(ConnectionProfile("bolt://*****:*****@host:8888', 'user': '******', }
def test_bolt_default_port(): data = dict(ConnectionProfile("bolt://host")) assert data == { 'address': IPv4Address(('host', 7687)), 'auth': ('neo4j', 'password'), 'host': 'host', 'password': '******', 'port': 7687, 'port_number': 7687, 'protocol': 'bolt', 'scheme': 'bolt', 'secure': False, 'verify': True, 'uri': 'bolt://host:7687', 'user': '******', }
def test_default_service_profile_with_routing_keyword(): data = dict(ServiceProfile("bolt://*****:*****@localhost:7687', 'user': '******', }
def test_default_service_profile_with_neo4j_plus_s_uri(): data = dict(ServiceProfile("neo4j+s://localhost:7687")) assert data == { 'address': IPv4Address(('localhost', 7687)), 'auth': ('neo4j', 'password'), 'host': 'localhost', 'password': '******', 'port': 7687, 'port_number': 7687, 'protocol': 'bolt', 'routing': True, 'scheme': 'neo4j+s', 'secure': True, 'verify': True, 'uri': 'neo4j+s://localhost:7687', 'user': '******', }
def test_to_dict_with_password(): p = ConnectionProfile() d = p.to_dict(include_password=True) assert d == { 'address': IPv4Address(('localhost', 7687)), 'auth': ('neo4j', 'password'), 'host': 'localhost', 'password': '******', 'port': 7687, 'port_number': 7687, 'protocol': 'bolt', 'scheme': 'bolt', 'secure': False, 'verify': True, 'uri': 'bolt://localhost:7687', 'user': '******', }
def test_http_uri_wth_secure_and_no_verify(): data = dict( ConnectionProfile("http://host:9999", secure=True, verify=False)) assert data == { 'address': IPv4Address(('host', 9999)), 'auth': ('neo4j', 'password'), 'host': 'host', 'password': '******', 'port': 9999, 'port_number': 9999, 'protocol': 'http', 'scheme': 'http+ssc', 'secure': True, 'verify': False, 'uri': 'http+ssc://host:9999', 'user': '******', }
def test_profile_from_dict(): dict1 = { 'address': IPv4Address(('localhost', 7687)), 'auth': ('neo4j', 'dictionary'), 'host': 'localhost', 'password': '******', 'port': 7687, 'port_number': 7687, 'protocol': 'bolt', 'scheme': 'bolt', 'secure': False, 'verify': True, 'uri': 'bolt://neo4j@localhost:7687', 'user': '******', } prof1 = ConnectionProfile(dict1) data = dict(prof1) assert data == dict1
def test_profile_from_profile(): prof1 = ConnectionProfile(password="******") prof2 = ConnectionProfile(prof1) data = dict(prof2) assert data == { 'address': IPv4Address(('localhost', 7687)), 'auth': ('neo4j', 'secret'), 'host': 'localhost', 'password': '******', 'port': 7687, 'port_number': 7687, 'protocol': 'bolt', 'scheme': 'bolt', 'secure': False, 'verify': True, 'uri': 'bolt://localhost:7687', 'user': '******', }
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', }