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:
Marko Budiselic
2017-06-12 11:29:46 +02:00
parent 3b88d7429f
commit 47b8a48df2
3 changed files with 55 additions and 0 deletions

View File

@@ -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
View 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

View 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!")