Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "neokit"]
path = neokit
url = https://github.com/nigelsmall/neokit.git
path = neokit
url = https://github.com/neo-technology/neokit.git
14 changes: 7 additions & 7 deletions examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# (* "good reason" is defined as knowing what you are doing)


auth_token = basic_auth("neo4j", "password")
auth_token = basic_auth("neo4j", "neo4j")


class FreshDatabaseTestCase(ServerTestCase):
Expand All @@ -48,7 +48,7 @@ class MinimalWorkingExampleTestCase(FreshDatabaseTestCase):

def test_minimal_working_example(self):
# tag::minimal-example[]
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"))
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"))
session = driver.session()

session.run("CREATE (a:Person {name:'Arthur', title:'King'})")
Expand All @@ -65,33 +65,33 @@ class ExamplesTestCase(FreshDatabaseTestCase):

def test_construct_driver(self):
# tag::construct-driver[]
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"))
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"))
# end::construct-driver[]
return driver

def test_configuration(self):
# tag::configuration[]
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), max_pool_size=10)
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), max_pool_size=10)
# end::configuration[]
return driver

@skipUnless(SSL_AVAILABLE, "Bolt over TLS is not supported by this version of Python")
def test_tls_require_encryption(self):
# tag::tls-require-encryption[]
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=True)
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=True)
# end::tls-require-encryption[]

@skipUnless(SSL_AVAILABLE, "Bolt over TLS is not supported by this version of Python")
def test_tls_trust_on_first_use(self):
# tag::tls-trust-on-first-use[]
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=True, trust=TRUST_ON_FIRST_USE)
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=True, trust=TRUST_ON_FIRST_USE)
# end::tls-trust-on-first-use[]
assert driver

@skip("testing verified certificates not yet supported ")
def test_tls_signed(self):
# tag::tls-signed[]
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=True, trust=TRUST_SIGNED_CERTIFICATES)
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=True, trust=TRUST_SIGNED_CERTIFICATES)
# end::tls-signed[]
assert driver

Expand Down
2 changes: 1 addition & 1 deletion neokit
Empty file removed requirements.txt
Empty file.
138 changes: 138 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

# Copyright (c) 2002-2016 "Neo Technology,"
# Network Engine for Objects in Lund AB [http://neotechnology.com]
#
# This file is part of Neo4j.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Usage: runtests.py
-h : show this help message
--test=name : run this specific test
--tests : run all unit tests
--examples : run all example tests
--tck : run tck tests
--neorun.start.args : args to neorun script
example:
python ./runtests.py --tests --examples --tck
python ./runtests.py --tests --examples --tck --neorun.start.args="-n 3.1 -p neo4j"
"""
from sys import argv, stdout, exit, version_info
from os import name, path
from atexit import register
import subprocess
import getopt

UNITTEST_RUNNER = "coverage run -m unittest discover -vfs "
BEHAVE_RUNNER="behave --tags=-db --tags=-tls --tags=-fixed_session_pool test/tck"

NEORUN_PATH = path.abspath('./neokit/neorun.py')
NEO4J_HOME = path.abspath('./build/neo4jhome')

is_windows = (name == 'nt')


def runpymodule(command):
commands = command.split()
if is_windows:
commands = ['powershell.exe', 'python', '-m'] + commands
return run0(commands)


def runcommand(command):
commands = command.split()
return runcommands(commands)


def runcommands(commands):
if is_windows:
commands = ['powershell.exe'] + commands
return run0(commands)


def run0(commands):
stdout.write("Running commands: %s\n" % commands)
p = subprocess.Popen(commands, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
retcode = p.wait()
if version_info < (3, 0):
stdout.write(out)
stdout.write(err)
else:
stdout.write(out.decode(stdout.encoding))
stdout.write(err.decode(stdout.encoding))
return retcode


def neorun(command):
runcommand('python ' + NEORUN_PATH + ' ' + command)


def main():
if len(argv) <= 1:
print_help()
exit(2)
try:
opts, args = getopt.getopt(argv[1:], "h", ["test=", "tests", "examples", "tck", "neorun.start.args="])
except getopt.GetoptError as err:
print(str(err))
print_help()
exit(2)
else:

stdout.write("Using python version:\n")
runcommand('python --version')
runpymodule('pip install --upgrade -r ./test_requirements.txt')
retcode = 0

register(neorun, '--stop=' + NEO4J_HOME)

neorun_args = '-p neo4j'
for opt, arg in opts:
if opt == '--neorun.start.args':
neorun_args = arg
break
neorun('--start=' + NEO4J_HOME + ' ' + neorun_args)

for opt, arg in opts:
if opt == '-h':
print_help()
retcode = 2

elif opt == "--tests":
retcode = retcode or runpymodule(UNITTEST_RUNNER + "test")
elif opt == "--test=":
retcode = retcode or runpymodule(UNITTEST_RUNNER + arg)
elif opt == "--example":
retcode = retcode or runpymodule(UNITTEST_RUNNER + "examples")
elif opt == "--tck":
retcode = runpymodule('coverage report --show-missing') or \
runcommands(["python", "-c", "\"from test.tck.configure_feature_files import *; set_up()\""]) or \
runpymodule(BEHAVE_RUNNER) or \
runcommands(["python", "-c", "\"from test.tck.configure_feature_files import *; clean_up()\""])

if retcode != 0:
break

return retcode


def print_help():
print(__doc__)


if __name__ == "__main__":
main()
98 changes: 4 additions & 94 deletions runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,99 +17,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

DRIVER_HOME=$(dirname $0)

NEORUN_OPTIONS=""
RUNNING=0
QUICK=0
KNOWN_HOSTS="${HOME}/.neo4j/known_hosts"
KNOWN_HOSTS_BACKUP="${KNOWN_HOSTS}.backup"

FG_BRIGHT_RED='\033[1;31m'
FG_DEFAULT='\033[0m'

# Parse options
while getopts ":dqr" OPTION
do
case ${OPTION} in
d)
NEORUN_OPTIONS="-f"
;;
q)
QUICK=1
;;
r)
RUNNING=1
;;
\?)
echo "Invalid option: -${OPTARG}" >&2
;;
esac
done
shift $(($OPTIND - 1))

if [ -z "${TEAMCITY_VERSION}" ]
then
UNITTEST="unittest"
if [ "$1" == "" ]; then
python ./runtests.py --tests --examples --tck
else
UNITTEST="teamcity.unittestpy"
#Example: python ./runtests.py --tests --examples --tck --neorun.start.args=”-n 3.1 -p neo4j”
python ./runtests.py --tests --examples --tck --neorun.start.args=\""$1"\"
fi

if [ -z "${TEST}" ]
then
TEST="test"
fi

VERSIONS=$*
if [ "${VERSIONS}" == "" ]
then
VERSIONS="nightly"
fi

function check_exit_status {
EXIT_STATUS=$1
if [ ${EXIT_STATUS} -ne 0 ]
then
echo ""
echo -e "${FG_BRIGHT_RED}Tests failed with status ${EXIT_STATUS}${FG_DEFAULT}"
exit ${EXIT_STATUS}
fi
}

# Run tests
echo "Using $(python --version)"
pip install --upgrade -r ${DRIVER_HOME}/test_requirements.txt
echo ""

TEST_RUNNER="coverage run -m ${UNITTEST} discover -vfs ${TEST}"
EXAMPLES_RUNNER="coverage run -m ${UNITTEST} discover -vfs examples"
BEHAVE_RUNNER="behave --tags=-db --tags=-tls --tags=-fixed_session_pool test/tck"

if [ ${RUNNING} -eq 1 ]
then
${TEST_RUNNER}
check_exit_status $?
else
export NEO4J_PASSWORD="password"

echo "Running unit tests"
neokit/neorun ${NEORUN_OPTIONS} "${TEST_RUNNER}" ${VERSIONS}
check_exit_status $?

if [ ${QUICK} -eq 0 ]
then
echo "Testing example code"
neokit/neorun ${NEORUN_OPTIONS} "${EXAMPLES_RUNNER}" ${VERSIONS}
check_exit_status $?

echo "Testing TCK"
coverage report --show-missing
python -c 'from test.tck.configure_feature_files import *; set_up()'
echo "Feature files downloaded"
neokit/neorun ${NEORUN_OPTIONS} "${BEHAVE_RUNNER}" ${VERSIONS}
python -c 'from test.tck.configure_feature_files import *; clean_up()'
echo "Feature files removed"

fi

fi
2 changes: 1 addition & 1 deletion test/tck/steps/driver_auth_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def step_impl(context):

@given("a driver is configured with auth enabled and correct password is provided")
def step_impl(context):
context.driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=False)
context.driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=False)


@given("a driver is configured with auth enabled and the wrong password is provided")
Expand Down
2 changes: 1 addition & 1 deletion test/tck/tck_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from test.tck.test_value import TestValue
from test.tck.resultparser import parse_values_to_comparable

driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=False)
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=False)
runners = []


Expand Down
2 changes: 1 addition & 1 deletion test/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from test.util import ServerTestCase


auth_token = basic_auth("neo4j", "password")
auth_token = basic_auth("neo4j", "neo4j")
from neo4j.v1.exceptions import ProtocolError


Expand Down