Skip to content

Commit f96e37b

Browse files
committed
Added first part of cypher compatabillity suite. Also added missing HEADER to test files
1 parent 7d8e86f commit f96e37b

File tree

5 files changed

+436
-10
lines changed

5 files changed

+436
-10
lines changed

test/tck/configure_feature_files.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
4+
# Copyright (c) 2002-2016 "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+
121
import os
222
import tarfile
323

24+
425
def clean_up():
526
dir_path = (os.path.dirname(os.path.realpath(__file__)))
627
files = os.listdir(dir_path)

test/tck/environment.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
4+
# Copyright (c) 2002-2016 "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+
121
import logging
222

3-
from test.tck import tck_util
423
from behave.log_capture import capture
5-
24+
from test.tck import tck_util
625

726
def before_all(context):
8-
# -- SET LOG LEVEL: behave --logging-level=ERROR ...
9-
# on behave command-line or in "behave.ini".
1027
context.config.setup_logging()
1128

29+
def before_scenario(context,scenario):
30+
#Empty database
31+
tck_util.send_string("MATCH (n) DETACH DELETE n")
32+
1233

1334
@capture
1435
def after_scenario(context, scenario):
1536
for step in scenario.steps:
1637
if step.status == 'failed':
1738
logging.error("Scenario :'%s' at step: '%s' failed! ", scenario.name, step.name)
18-
logging.debug("Expected result: %s", tck_util.as_cypher_text(context.expected))
19-
logging.debug("Actual result: %s", tck_util.as_cypher_text(context.results))
2039
if step.status == 'skipped':
2140
logging.warn("Scenario :'%s' at step: '%s' was skipped! ", scenario.name, step.name)
2241
if step.status == 'passed':

test/tck/steps/bolt_type_steps.py

Lines changed: 142 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
4+
# Copyright (c) 2002-2016 "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+
121
from behave import *
22+
import json
223

24+
from neo4j.v1 import GraphDatabase
325
from test.tck import tck_util
426

527
use_step_matcher("re")
628

729

830
@given("A running database")
931
def step_impl(context):
10-
return None
11-
# check if running
32+
tck_util.send_string("RETURN 1")
1233

1334

1435
@given("a value (?P<input>.+) of type (?P<bolt_type>.+)")
@@ -121,4 +142,122 @@ def step_impl(context):
121142
assert len(context.results) > 0
122143
for result in context.results.values():
123144
result_value = result[0].values()[0]
124-
assert result_value == context.expected
145+
assert result_value == context.expected
146+
147+
148+
@given("A driver containing a session pool of size (?P<size>\d+)")
149+
def step_impl(context, size):
150+
context.driver = GraphDatabase.driver("bolt://localhost", max_pool_size=1)
151+
152+
153+
@when("acquiring a session from the driver")
154+
def step_impl(context):
155+
context.session = context.driver.session()
156+
157+
158+
@step('with the session running the Cypher statement "(?P<statement>.+)"')
159+
def step_impl(context, statement):
160+
context.cursor = context.session.run(statement)
161+
162+
163+
@step("pulling the result records")
164+
def step_impl(context):
165+
context.cursor.consume()
166+
167+
168+
@then("acquiring a session from the driver should not be possible")
169+
def step_impl(context):
170+
try:
171+
context.session = context.driver.session()
172+
except:
173+
assert True
174+
else:
175+
assert False
176+
177+
178+
@then("acquiring a session from the driver should be possible")
179+
def step_impl(context):
180+
_ = context.driver.session()
181+
assert True
182+
183+
184+
@given("init: (?P<statement>.+);")
185+
def step_impl(context, statement):
186+
tck_util.send_string(statement)
187+
188+
189+
@when("running: (?P<statement>.+);")
190+
def step_impl(context, statement):
191+
context.results = {"as_string": tck_util.send_string(statement)}
192+
193+
194+
@given("an empty database")
195+
def step_impl(context):
196+
tck_util.send_string("MATCH (n) DETACH DELETE n")
197+
198+
199+
@then("result should be a path p containing")
200+
def step_impl(context):
201+
result = context.results["as_string"]
202+
given = tck_util.result_to_set(result)
203+
expected = tck_util.text_path_to_set(context.table)
204+
if given != expected:
205+
raise Exception("Path does not match given: %s expected: %s" % (given, expected))
206+
207+
208+
@then("result should be integer\(s\)")
209+
def step_impl(context):
210+
result = context.results["as_string"]
211+
given = tck_util.result_to_set(result)
212+
expected = tck_util.text_int_to_set(context.table)
213+
if given != expected:
214+
raise Exception("Integers does not match given: %s expected: %s" % (given, expected))
215+
216+
217+
@then("result should be node\(s\)")
218+
def step_impl(context):
219+
result = context.results["as_string"]
220+
given = tck_util.result_to_set(result)
221+
expected = tck_util.text_node_to_set(context.table)
222+
if given != expected:
223+
raise Exception("Nodes does not match given: %s expected: %s" % (given, expected))
224+
225+
226+
@then("result should be string\(s\)")
227+
def step_impl(context):
228+
result = context.results["as_string"]
229+
given = tck_util.result_to_set(result)
230+
expected = tck_util.text_string_to_set(context.table)
231+
if given != expected:
232+
raise Exception("Strings does not match given: %s expected: %s" % (given, expected))
233+
234+
235+
@then("result should be relationship\(s\)")
236+
def step_impl(context):
237+
result = context.results["as_string"]
238+
given = tck_util.result_to_set(result)
239+
expected = tck_util.text_relationship_to_set(context.table)
240+
if given != expected:
241+
raise Exception("Relationship does not match given: %s expected: %s" % (given, expected))
242+
243+
244+
@then("result should be empty")
245+
def step_impl(context):
246+
assert context.results
247+
for result in context.results.values():
248+
assert len(result) == 0
249+
250+
251+
@then('result should be node "(?P<n1>.+)" node "(?P<n2>.+)" and int "(?P<len>\d+)"')
252+
def step_impl(context, n1, n2, len):
253+
result = context.results["as_string"]
254+
given = tck_util.single_result_to_values(result)
255+
expected = tck_util.node_node_int_to_values(n1, n2, len)
256+
if given != expected:
257+
raise Exception("Mixed response does not match given: %s expected: %s" % (given, expected))
258+
259+
260+
@when('running "(?P<parameters>.+)": (?P<statement>.+);')
261+
def step_impl(context, parameters, statement):
262+
parameters = json.loads(parameters)
263+
context.results = {"as_string": tck_util.send_parameters(statement, parameters)}

0 commit comments

Comments
 (0)