Example #1
0
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': '******',
    }
Example #2
0
def test_bolt_uri_only():
    data = dict(ConnectionProfile("bolt://*****:*****@host:9999',
        'user': '******',
    }
Example #3
0
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': '******',
    }
Example #4
0
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': '******',
    }
Example #5
0
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': '******',
    }
Example #6
0
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': '******',
    }
Example #7
0
def test_https_uri_without_secure():
    data = dict(ConnectionProfile("https://*****:*****@host:9999',
        'user': '******',
    }
Example #8
0
def test_uri_and_port():
    data = dict(ConnectionProfile("bolt://*****:*****@host:8888',
        'user': '******',
    }
Example #9
0
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': '******',
    }
Example #10
0
def test_default_service_profile_with_routing_keyword():
    data = dict(ServiceProfile("bolt://*****:*****@localhost:7687',
        'user': '******',
    }
Example #11
0
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': '******',
    }
Example #12
0
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': '******',
    }
Example #13
0
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': '******',
    }
Example #14
0
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
Example #15
0
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': '******',
    }
Example #16
0
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',
    }