示例#1
0
async def a_main(prog):
    parser = ArgumentParser(prog=prog)
    parser.add_argument("cypher", help="Cypher query to execute")
    parser.add_argument("-a",
                        "--auth",
                        metavar="USER:PASSWORD",
                        default="",
                        help="user name and password")
    parser.add_argument("-s",
                        "--server-addr",
                        metavar="HOST:PORT",
                        default=":7687",
                        help="address of server")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        help="increase output verbosity")
    parsed = parser.parse_args()
    if parsed.verbose:
        watch("neo4j")
    addr = Address.parse(parsed.server_addr)
    user, _, password = parsed.auth.partition(":")
    if not password:
        password = getpass()
    auth = (user or "neo4j", password)
    bolt = await Bolt.open(addr, auth=auth)
    try:
        result = await bolt.run(parsed.cypher)
        print("\t".join(await result.fields()))
        async for record in result:
            print("\t".join(map(repr, record)))
    finally:
        await bolt.close()
示例#2
0
def service(request):
    global NEO4J_SERVICE
    if NEO4J_DEBUG:
        from neo4j.debug import watch
        watch("neo4j")
    with NEO4J_LOCK:
        assert NEO4J_SERVICE is None
        NEO4J_SERVICE = Neo4jService(auth=NEO4J_AUTH, image=request.param)
        NEO4J_SERVICE.start(timeout=300)
        yield NEO4J_SERVICE
        if NEO4J_SERVICE is not None:
            NEO4J_SERVICE.stop(timeout=300)
            NEO4J_SERVICE = None
def service(request):
    global NEO4J_SERVICE
    if NEO4J_DEBUG:
        from neo4j.debug import watch
        watch("neo4j", "boltkit")
    with NEO4J_LOCK:
        assert NEO4J_SERVICE is None
        NEO4J_SERVICE = existing_service
        if existing_service:
            NEO4J_SERVICE = existing_service
        else:
            NEO4J_SERVICE = Neo4jService(auth=NEO4J_AUTH, image=request.param,
                                         n_cores=NEO4J_CORES, n_replicas=NEO4J_REPLICAS)
            NEO4J_SERVICE.start(timeout=300)
        yield NEO4J_SERVICE
        if NEO4J_SERVICE is not None:
            NEO4J_SERVICE.stop(timeout=300)
            NEO4J_SERVICE = None
def service(request):
    global NEO4J_SERVICE
    if NEO4J_DEBUG:
        from neo4j.debug import watch
        watch("neo4j", "boltkit")
    with NEO4J_LOCK:
        assert NEO4J_SERVICE is None
        NEO4J_SERVICE = existing_service
        if existing_service:
            NEO4J_SERVICE = existing_service
        else:
            try:
                NEO4J_SERVICE = Neo4jService(auth=NEO4J_AUTH, image=request.param, n_cores=NEO4J_CORES, n_replicas=NEO4J_REPLICAS)
                NEO4J_SERVICE.start(timeout=300)
            except urllib.error.HTTPError as error:
                # pytest.skip(str(error))
                pytest.xfail(str(error) + " " + request.param)
        yield NEO4J_SERVICE
        if NEO4J_SERVICE is not None:
            NEO4J_SERVICE.stop(timeout=300)
            NEO4J_SERVICE = None
示例#5
0
    Config,
    PoolConfig,
    WorkspaceConfig,
    SessionConfig,
)
from neo4j.api import (
    TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
    WRITE_ACCESS,
    READ_ACCESS,
)

# python -m pytest tests/unit/test_conf.py -s -v

from neo4j.debug import watch

watch("neo4j")

test_pool_config = {
    "connection_timeout": 30.0,
    "init_size": 1,
    "keep_alive": True,
    "max_connection_lifetime": 3600,
    "max_connection_pool_size": 100,
    "protocol_version": None,
    "resolver": None,
    "encrypted": False,
    "user_agent": "test",
    "trust": TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
}

test_session_config = {