Skip to content

Commit a52948b

Browse files
committed
Merge pull request #9 from neo4j/test-refactoring
Test refactoring
2 parents f785779 + 942b39f commit a52948b

File tree

8 files changed

+66
-319
lines changed

8 files changed

+66
-319
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "neokit"]
2+
path = neokit
3+
url = git@github.com:nigelsmall/neokit.git

neoget.sh

Lines changed: 0 additions & 163 deletions
This file was deleted.

neokit

Submodule neokit added at 0f5a119

runtests.sh

Lines changed: 46 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,39 @@
11
#!/usr/bin/env bash
22

3-
if [[ $0 == /* ]]
4-
then
5-
HOME=$(dirname $0)
6-
else
7-
HOME=$(pwd)/$(dirname $0)
8-
fi
9-
cd ${HOME}
10-
11-
DOT_TEST=${HOME}/.test
12-
NEOGET=${HOME}/neoget.sh
3+
# Copyright (c) 2002-2015 "Neo Technology,"
4+
# Network Engine for Objects in Lund AB [http://neotechnology.com]
5+
#
6+
# This file is part of Neo4j.
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License");
9+
# you may not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
20+
DRIVER_HOME=$(dirname $0)
1321

1422
FORCE_DOWNLOAD=0
1523
RUNNING=0
1624

17-
function runserverandtests {
18-
19-
PYTHON_VERSION=$(python --version)
20-
NEO_VERSION=$1
21-
22-
echo "======================================================================"
23-
echo "Running with ${PYTHON_VERSION} against Neo4j ${NEO_VERSION}"
24-
echo "----------------------------------------------------------------------"
25-
26-
cd ${HOME}
27-
28-
if [ ${FORCE_DOWNLOAD} -ne 0 ]
29-
then
30-
rm -rf ${DOT_TEST}
31-
fi
32-
mkdir -p ${DOT_TEST} 2> /dev/null
33-
34-
pushd ${DOT_TEST} > /dev/null
35-
tar xf $(${NEOGET} ${NEOGET_ARGS})
36-
NEO_HOME=$(ls -1Ft | grep "/$" | head -1) # finds the newest directory relative to .test
37-
echo "xx.bolt.enabled=true" >> ${NEO_HOME}/conf/neo4j-server.properties
38-
${NEO_HOME}/bin/neo4j start
39-
STATUS=$?
40-
if [ ${STATUS} -ne 0 ]
41-
then
42-
exit ${STATUS}
43-
fi
44-
popd > /dev/null
45-
46-
echo -n "Testing"
47-
coverage run -m unittest "${TESTS}"
48-
49-
pushd ${DOT_TEST} > /dev/null
50-
${NEO_HOME}/bin/neo4j stop
51-
rm -rf ${NEO_HOME}
52-
popd > /dev/null
53-
54-
coverage report --show-missing
55-
56-
echo "======================================================================"
57-
echo ""
58-
59-
}
60-
61-
function runtests {
62-
63-
PYTHON_VERSION=$(python --version)
64-
65-
echo "======================================================================"
66-
echo "Running with ${PYTHON_VERSION} against running Neo4j instance"
67-
echo "----------------------------------------------------------------------"
68-
69-
cd ${HOME}
70-
71-
echo -n "Testing"
72-
coverage run -m unittest test
73-
74-
coverage report --show-missing
75-
76-
echo "======================================================================"
77-
echo ""
25+
if [ -z "${TEST}" ]
26+
then
27+
TEST="test"
28+
fi
7829

79-
}
30+
VERSIONS=$*
31+
if [ "${VERSIONS}" == "" ]
32+
then
33+
VERSIONS="nightly"
34+
fi
8035

36+
# Parse options
8137
while getopts ":dr" OPTION
8238
do
8339
case ${OPTION} in
@@ -93,16 +49,26 @@ do
9349
esac
9450
done
9551

96-
TESTS=$1
97-
if [ "${TESTS}" == "" ]
52+
# Run tests
53+
echo "Running tests with $(python --version)"
54+
pip install --upgrade -r ${DRIVER_HOME}/test_requirements.txt
55+
echo ""
56+
TEST_RUNNER="coverage run -m unittest discover -vfs ${TEST}"
57+
if [ ${RUNNING} -eq 1 ]
9858
then
99-
TESTS="test"
59+
${TEST_RUNNER}
60+
EXIT_STATUS=$?
61+
else
62+
neokit/neorun "${TEST_RUNNER}" ${VERSIONS}
63+
EXIT_STATUS=$?
64+
if [ ${EXIT_STATUS} -eq 0 ]
65+
then
66+
coverage report --show-missing
67+
fi
10068
fi
10169

102-
if [ ${RUNNING} -eq 1 ]
70+
# Exit correctly
71+
if [ ${EXIT_STATUS} -ne 0 ]
10372
then
104-
runtests
105-
else
106-
NEOGET_ARGS="-eax"
107-
runserverandtests "3.0.0-M01"
73+
exit ${EXIT_STATUS}
10874
fi

test/__init__.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +0,0 @@
1-
#!/usr/bin/env python
2-
# -*- encoding: utf-8 -*-
3-
4-
# Copyright (c) 2002-2015 "Neo Technology,"
5-
# Network Engine for Objects in Lund AB [http://neotechnology.com]
6-
#
7-
# This file is part of Neo4j.
8-
#
9-
# Licensed under the Apache License, Version 2.0 (the "License");
10-
# you may not use this file except in compliance with the License.
11-
# You may obtain a copy of the License at
12-
#
13-
# http://www.apache.org/licenses/LICENSE-2.0
14-
#
15-
# Unless required by applicable law or agreed to in writing, software
16-
# distributed under the License is distributed on an "AS IS" BASIS,
17-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18-
# See the License for the specific language governing permissions and
19-
# limitations under the License.
20-
21-
from .session_test import *
22-
from .packstream_test import *
23-
from .typesystem_test import *

test/packstream_test.py renamed to test/test_packstream.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
# See the License for the specific language governing permissions and
1919
# limitations under the License.
2020

21+
2122
from collections import OrderedDict
2223
from io import BytesIO
2324
from math import pi
2425
import struct
25-
from unittest import main, TestCase
26+
from unittest import TestCase
2627

2728
from neo4j.packstream import Packer, Unpacker, packb
2829

@@ -270,7 +271,3 @@ def test_empty_struct(self):
270271

271272
def test_tiny_struct(self):
272273
assert_packable((b"Z", (u"A", 1)), b"\xB2Z\x81A\x01")
273-
274-
275-
if __name__ == "__main__":
276-
main()

0 commit comments

Comments
 (0)