2424from behave import *
2525
2626from neo4j .v1 import GraphDatabase
27- from test .tck import tck_util
28- from test .tck .tck_util import to_unicode
27+ from test .tck .tck_util import to_unicode , Type , send_string , send_parameters , string_to_type
2928
3029from neo4j .v1 import compat
3130use_step_matcher ("re" )
3231
3332
3433@given ("A running database" )
3534def step_impl (context ):
36- tck_util . send_string ("RETURN 1" )
35+ send_string ("RETURN 1" )
3736
3837
3938@given ("a value (?P<input>.+) of type (?P<bolt_type>.+)" )
4039def step_impl (context , input , bolt_type ):
41- context .expected = get_bolt_value (bolt_type , input )
40+ context .expected = get_bolt_value (string_to_type ( bolt_type ) , input )
4241
4342
4443@given ("a value of type (?P<bolt_type>.+)" )
4544def step_impl (context , bolt_type ):
46- context .expected = get_bolt_value (bolt_type , u' ' )
45+ context .expected = get_bolt_value (string_to_type ( bolt_type ) , u' ' )
4746
4847
4948@given ("a list value (?P<input>.+) of type (?P<bolt_type>.+)" )
5049def step_impl (context , input , bolt_type ):
51- context .expected = get_list_from_feature_file (input , bolt_type )
50+ context .expected = get_list_from_feature_file (input , string_to_type ( bolt_type ) )
5251
5352
5453@given ("an empty list L" )
@@ -68,12 +67,12 @@ def step_impl(context, size):
6867
6968@given ("a List of size (?P<size>\d+) and type (?P<type>.+)" )
7069def step_impl (context , size , type ):
71- context .expected = get_list_of_random_type (int (size ), type )
70+ context .expected = get_list_of_random_type (int (size ), string_to_type ( type ) )
7271
7372
7473@given ("a Map of size (?P<size>\d+) and type (?P<type>.+)" )
7574def step_impl (context , size , type ):
76- context .expected = get_dict_of_random_type (int (size ), type )
75+ context .expected = get_dict_of_random_type (int (size ), string_to_type ( type ) )
7776
7877
7978@step ("adding a table of lists to the list L" )
@@ -112,25 +111,22 @@ def step_impl(context):
112111
113112@when ("the driver asks the server to echo this value back" )
114113def step_impl (context ):
115- context .results = {}
116- context .results ["as_string" ] = tck_util .send_string ("RETURN " + as_cypher_text (context .expected ))
117- context .results ["as_parameters" ] = tck_util .send_parameters ("RETURN {input}" , {'input' : context .expected })
114+ context .results = {"as_string" : send_string ("RETURN " + as_cypher_text (context .expected )),
115+ "as_parameters" : send_parameters ("RETURN {input}" , {'input' : context .expected })}
118116
119117
120118@when ("the driver asks the server to echo this list back" )
121119def step_impl (context ):
122120 context .expected = context .L
123- context .results = {}
124- context .results ["as_string" ] = tck_util .send_string ("RETURN " + as_cypher_text (context .expected ))
125- context .results ["as_parameters" ] = tck_util .send_parameters ("RETURN {input}" , {'input' : context .expected })
121+ context .results = {"as_string" : send_string ("RETURN " + as_cypher_text (context .expected )),
122+ "as_parameters" : send_parameters ("RETURN {input}" , {'input' : context .expected })}
126123
127124
128125@when ("the driver asks the server to echo this map back" )
129126def step_impl (context ):
130127 context .expected = context .M
131- context .results = {}
132- context .results ["as_string" ] = tck_util .send_string ("RETURN " + as_cypher_text (context .expected ))
133- context .results ["as_parameters" ] = tck_util .send_parameters ("RETURN {input}" , {'input' : context .expected })
128+ context .results = {"as_string" : send_string ("RETURN " + as_cypher_text (context .expected )),
129+ "as_parameters" : send_parameters ("RETURN {input}" , {'input' : context .expected })}
134130
135131
136132@step ("the value given in the result should be the same as what was sent" )
@@ -178,15 +174,15 @@ def step_impl(context):
178174
179175
180176def get_bolt_value (type , value ):
181- if type == 'Integer' :
177+ if type == Type . INTEGER :
182178 return int (value )
183- if type == 'Float' :
179+ if type == Type . FLOAT :
184180 return float (value )
185- if type == 'String' :
181+ if type == Type . STRING :
186182 return to_unicode (value )
187- if type == 'Null' :
183+ if type == Type . NULL :
188184 return None
189- if type == 'Boolean' :
185+ if type == Type . BOOLEAN :
190186 return bool (value )
191187 raise ValueError ('No such type : %s' % type )
192188
@@ -242,19 +238,19 @@ def _get_random_func(type):
242238 def get_none ():
243239 return None
244240
245- if type == 'Integer' :
241+ if type == Type . INTEGER :
246242 fu = random .randint
247243 args = [- 9223372036854775808 , 9223372036854775808 ]
248- elif type == 'Float' :
244+ elif type == Type . FLOAT :
249245 fu = random .random
250246 args = []
251- elif type == 'String' :
247+ elif type == Type . STRING :
252248 fu = get_random_string
253249 args = [3 ]
254- elif type == 'Null' :
250+ elif type == Type . NULL :
255251 fu = get_none
256252 args = []
257- elif type == 'Boolean' :
253+ elif type == Type . BOOLEAN :
258254 fu = get_random_bool
259255 args = []
260256 else :
0 commit comments