Remove v1 driver test for python ()

This commit is contained in:
antonio2368 2021-03-16 11:42:36 +01:00 committed by GitHub
parent 866ed45562
commit c240b5b564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 153 deletions

View File

@ -1,25 +0,0 @@
#!/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!")

View File

@ -1,39 +0,0 @@
#!/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)
query_template = 'CREATE (n {name:"%s"})'
template_size = len(query_template) - 2 # because of %s
min_len = 1
max_len = 1000000
# binary search because we have to find the maximum size (in number of chars)
# of a query that can be executed via driver
while True:
assert min_len > 0 and max_len > 0, \
"The lengths have to be positive values! If this happens something" \
" is terrible wrong with min & max lengths OR the database" \
" isn't available."
property_size = (max_len + min_len) // 2
try:
driver.session().run(query_template % ("a" * property_size)).consume()
if min_len == max_len or property_size + 1 > max_len:
break
min_len = property_size + 1
except Exception as e:
print("Query size %s is too big!" % (template_size + property_size))
max_len = property_size - 1
assert property_size == max_len, "max_len probably has to be increased!"
print("\nThe max length of a query from Python driver is: %s\n" %
(template_size + property_size))
# sessions are not closed bacause all sessions that are
# executed with wrong query size might be broken
driver.close()

View File

@ -1,33 +0,0 @@
#!/bin/bash -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
# system check
if ! which virtualenv >/dev/null; then
echo "Please install virtualenv!"
exit 1
fi
# setup virtual environment
if [ ! -d "ve3" ]; then
# Driver downloaded from: https://pypi.org/project/neo4j-driver/1.5.3/
wget -nv https://s3-eu-west-1.amazonaws.com/deps.memgraph.io/drivers/python/neo4j-driver-1.5.3.tar.gz -O neo4j-driver.tar.gz || exit 1
tar -xzf neo4j-driver.tar.gz || exit 1
mv neo4j-driver-1.5.3 neo4j-driver || exit 1
virtualenv -p python3 ve3 || exit 1
source ve3/bin/activate
cd neo4j-driver
python3 setup.py install || exit 1
cd ..
deactivate
rm -rf neo4j-driver neo4j-driver.tar.gz || exit 1
fi
# activate virtualenv
source ve3/bin/activate
# execute test
python3 basic.py || exit 1
python3 max_query_length.py || exit 1
python3 transactions.py || exit 1

View File

@ -1,56 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from neo4j.v1 import GraphDatabase, basic_auth
from neo4j.exceptions import ClientError, TransientError
def tx_error(tx, name, name2):
a = tx.run("CREATE (a:Person {name: $name}) RETURN a", name=name).data()
print(a[0]['a'])
tx.run("CREATE (").consume()
a = tx.run("CREATE (a:Person {name: $name}) RETURN a", name=name2).data()
print(a[0]['a'])
def tx_good(tx, name, name2):
a = tx.run("CREATE (a:Person {name: $name}) RETURN a", name=name).data()
print(a[0]['a'])
a = tx.run("CREATE (a:Person {name: $name}) RETURN a", name=name2).data()
print(a[0]['a'])
def tx_too_long(tx):
tx.run("MATCH (a), (b), (c), (d), (e), (f) RETURN COUNT(*) AS cnt")
with GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("", ""),
encrypted=False) as driver:
def add_person(f, name, name2):
with driver.session() as session:
session.write_transaction(f, name, name2)
# Wrong query.
try:
add_person(tx_error, "mirko", "slavko")
except ClientError:
pass
# Correct query.
add_person(tx_good, "mirka", "slavka")
# Setup for next query.
with driver.session() as session:
session.run("UNWIND range(1, 100000) AS x CREATE ()")
# Query that will run for a very long time, transient error expected.
timed_out = False
try:
with driver.session() as session:
session.run("MATCH (a), (b), (c), (d), (e), (f) RETURN COUNT(*) AS cnt")
except TransientError:
timed_out = True
if timed_out:
print("The query timed out as was expected.")
else:
raise Exception("The query should have timed out, but it didn't!")
print("All ok!")