Python driver test.
Summary: Python driver test. Equivalent to all other driver tests. Reviewers: mferencevic, teon.banek Reviewed By: teon.banek Subscribers: pullbot, buda Differential Revision: https://phabricator.memgraph.io/D452
This commit is contained in:
3
tests/drivers/.gitignore
vendored
3
tests/drivers/.gitignore
vendored
@@ -5,3 +5,6 @@ java/*.class
|
||||
# javascript driver
|
||||
javascript/node_modules
|
||||
javascript/package-lock.json
|
||||
|
||||
# python driver
|
||||
python/ve3
|
||||
|
||||
27
tests/drivers/python/run.sh
Executable file
27
tests/drivers/python/run.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
VIRTUALENV=virtualenv
|
||||
PIP=pip
|
||||
PYTHON=python
|
||||
WORKING_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
set -e
|
||||
|
||||
cd ${WORKING_DIR}
|
||||
|
||||
# system check
|
||||
if ! which $VIRTUALENV >/dev/null; then
|
||||
echo "Please install virtualenv!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# setup virtual environment
|
||||
if [ ! -d "ve3" ]; then
|
||||
virtualenv -p python3 ve3
|
||||
fi
|
||||
source ve3/bin/activate
|
||||
$PIP install --upgrade pip
|
||||
$PIP install neo4j-driver
|
||||
|
||||
# execute test
|
||||
$PYTHON test.py
|
||||
25
tests/drivers/python/test.py
Normal file
25
tests/drivers/python/test.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from neo4j.v1 import GraphDatabase, basic_auth
|
||||
|
||||
driver = GraphDatabase.driver("bolt://localhost:7687",
|
||||
auth=basic_auth("", ""),
|
||||
encrypted=False)
|
||||
session = driver.session()
|
||||
|
||||
session.run('MATCH (n) DETACH DELETE n').consume()
|
||||
session.run('CREATE (alice:Person {name: "Alice", age: 22})').consume()
|
||||
|
||||
returned_result_set = session.run('MATCH (n) RETURN n').data()
|
||||
returned_result = returned_result_set.pop()
|
||||
alice = returned_result["n"]
|
||||
|
||||
print(alice['name'])
|
||||
print(alice.labels)
|
||||
print(alice['age'])
|
||||
|
||||
session.close()
|
||||
driver.close()
|
||||
|
||||
print("All ok!")
|
||||
Reference in New Issue
Block a user