Skip to content

Commit ffc8ba3

Browse files
author
Zhen Li
committed
Merge pull request #5 from neo4j/fix-failing-build
Fix the failure in CI
2 parents dd85bad + 2a4a582 commit ffc8ba3

File tree

7 files changed

+60
-21
lines changed

7 files changed

+60
-21
lines changed

neo4j/compat.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,24 @@
3434
except NameError:
3535
integer = int
3636
string = str
37+
38+
def hex2(x):
39+
if x < 0x10:
40+
return "0" + hex(x)[2:].upper()
41+
else:
42+
return hex(x)[2:].upper()
43+
3744
else:
3845
integer = (int, long)
3946
string = (str, unicode)
4047

48+
def hex2(x):
49+
x = ord(x)
50+
if x < 0x10:
51+
return "0" + hex(x)[2:].upper()
52+
else:
53+
return hex(x)[2:].upper()
54+
4155

4256
try:
4357
from multiprocessing import Array, Process

neo4j/connection.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020

2121
from __future__ import division
2222

23-
from collections import deque, namedtuple
23+
from collections import deque
2424
from io import BytesIO
2525
import logging
2626
from os import environ
2727
from select import select
2828
from socket import create_connection, SHUT_RDWR
2929
from struct import pack as struct_pack, unpack as struct_unpack, unpack_from as struct_unpack_from
3030

31-
from .compat import perf_counter, secure_socket
31+
from .compat import hex2, secure_socket
3232
from .exceptions import ProtocolError
33-
from .packstream import Packer, Unpacker, Structure
33+
from .packstream import Packer, Unpacker
3434

3535

3636
DEFAULT_PORT = 7687
@@ -70,13 +70,6 @@
7070
log_error = log.error
7171

7272

73-
def hex2(x):
74-
if x < 0x10:
75-
return "0" + hex(x)[2:].upper()
76-
else:
77-
return hex(x)[2:].upper()
78-
79-
8073
class ChunkChannel(object):
8174
""" Reader/writer for chunked data.
8275
@@ -199,7 +192,7 @@ def on_success(self, metadata):
199192
def on_failure(self, metadata):
200193
pass
201194

202-
def on_ignored(self, metadata):
195+
def on_ignored(self, metadata=None):
203196
pass
204197

205198

neo4j/session.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,15 @@ def run(self, statement, parameters=None):
204204
if isinstance(statement, bytes):
205205
statement = statement.decode("UTF-8")
206206

207-
parameters = dict(parameters or {})
207+
params = {}
208+
for key, value in (parameters or {}).items():
209+
if isinstance(key, bytes):
210+
key = key.decode("UTF-8")
211+
if isinstance(value, bytes):
212+
params[key] = value.decode("UTF-8")
213+
else:
214+
params[key] = value
215+
parameters = params
208216

209217
t = BenchTest()
210218
t.init = perf_counter()

neoget.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ EDITION="community"
2121
MODE=""
2222
CHECK_EXISTS=0
2323
ALL_VERSIONS="2.3.0-M02 2.2.2 2.1.8 2.0.4"
24-
ALPHA_VERSION="3.0.0-alpha"
24+
ALPHA_VERSION="3.0.0-M01"
2525

2626
function usage {
2727
SCRIPT=$(basename $0)
@@ -83,7 +83,7 @@ function download {
8383
fi
8484
if [ $DOWNLOAD -eq 1 ]
8585
then
86-
if [[ "${VERSION}" == *"alpha"* ]]
86+
if [[ "$ALL_VERSIONS" == "$ALPHA_VERSION" ]]
8787
then
8888
URL="${ALPHA}/${ARCHIVE}"
8989
else
@@ -161,4 +161,3 @@ then
161161
else
162162
download
163163
fi
164-

runtests.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function runserverandtests {
3232
mkdir -p ${DOT_TEST} 2> /dev/null
3333

3434
pushd ${DOT_TEST} > /dev/null
35-
tar xf $(${NEOGET} -ex ${NEO_VERSION})
35+
tar xf $(${NEOGET} ${NEOGET_ARGS})
3636
NEO_HOME=$(ls -1Ft | grep "/$" | head -1) # finds the newest directory relative to .test
3737
echo "xx.bolt.enabled=true" >> ${NEO_HOME}/conf/neo4j-server.properties
3838
${NEO_HOME}/bin/neo4j start
@@ -44,7 +44,7 @@ function runserverandtests {
4444
popd > /dev/null
4545

4646
echo -n "Testing"
47-
coverage run -m unittest test
47+
coverage run -m unittest "${TESTS}"
4848

4949
pushd ${DOT_TEST} > /dev/null
5050
${NEO_HOME}/bin/neo4j stop
@@ -93,9 +93,16 @@ do
9393
esac
9494
done
9595

96+
TESTS=$1
97+
if [ "${TESTS}" == "" ]
98+
then
99+
TESTS="test"
100+
fi
101+
96102
if [ ${RUNNING} -eq 1 ]
97103
then
98104
runtests
99105
else
100-
runserverandtests "3.0.0-alpha"
106+
NEOGET_ARGS="-eax"
107+
runserverandtests "3.0.0-M01"
101108
fi

test/session_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ def test_can_run_simple_statement(self):
6565
session.close()
6666
assert count == 1
6767

68+
def test_fails_on_bad_syntax(self):
69+
session = GraphDatabase.driver("bolt://localhost").session()
70+
try:
71+
session.run("X").consume()
72+
except CypherError:
73+
assert True
74+
else:
75+
assert False
76+
77+
def test_fails_on_missing_parameter(self):
78+
session = GraphDatabase.driver("bolt://localhost").session()
79+
try:
80+
session.run("RETURN {x}").consume()
81+
except CypherError:
82+
assert True
83+
else:
84+
assert False
85+
6886
def test_can_run_simple_statement_from_bytes_string(self):
6987
session = GraphDatabase.driver("bolt://localhost").session()
7088
count = 0

test/typesystem_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_can_hydrate_node_structure(self):
168168
alice = hydrated(struct)
169169
assert alice.identity == "node/123"
170170
assert alice.labels == {"Person"}
171-
assert alice.keys() == {"name"}
171+
assert set(alice.keys()) == {"name"}
172172
assert alice.get("name") == "Alice"
173173

174174
def test_hydrating_unknown_structure_returns_same(self):
@@ -187,7 +187,7 @@ def test_can_hydrate_in_list(self):
187187
alice, = alice_in_list
188188
assert alice.identity == "node/123"
189189
assert alice.labels == {"Person"}
190-
assert alice.keys() == {"name"}
190+
assert set(alice.keys()) == {"name"}
191191
assert alice.get("name") == "Alice"
192192

193193
def test_can_hydrate_in_dict(self):
@@ -200,7 +200,7 @@ def test_can_hydrate_in_dict(self):
200200
alice = alice_in_dict["foo"]
201201
assert alice.identity == "node/123"
202202
assert alice.labels == {"Person"}
203-
assert alice.keys() == {"name"}
203+
assert set(alice.keys()) == {"name"}
204204
assert alice.get("name") == "Alice"
205205

206206

0 commit comments

Comments
 (0)