11
11
from_hex = lambda x : binascii .unhexlify ('' .join (x .split ()))
12
12
to_hex = lambda x : binascii .hexlify (x )
13
13
14
-
15
14
import tarantool .response
16
-
15
+ from tarantool .schema import Schema
16
+
17
+ class ConnectionMock (object ):
18
+ def __init__ (self , default_type ):
19
+ self .schema = Schema ({
20
+ 1 : {
21
+ 'name' : 'users' ,
22
+ 'default_type' : default_type ,
23
+ 'fields' : {
24
+ 0 : ('f1' , default_type ),
25
+ 1 : ('f2' , default_type ),
26
+ 2 : ('f3' , default_type ),
27
+ },
28
+ 'indexes' : {
29
+ 0 : ('pk' , [0 , 0 ]),
30
+ },
31
+ }
32
+ })
17
33
18
34
class field (unittest .TestCase ):
19
35
'''
@@ -168,7 +184,7 @@ def test__init_single(self):
168
184
"04 01000000" + "05 4a4b4c4d4e" )
169
185
170
186
self .assertEqual (
171
- tarantool .response .Response (header , body ),
187
+ tarantool .response .Response (ConnectionMock ( tarantool . STR ), header , body ),
172
188
[(b"\x01 \x00 \x00 \x00 " , b"JKLMN" )],
173
189
"Create Response instance: single record"
174
190
)
@@ -200,7 +216,7 @@ def test__init_multiple(self):
200
216
)
201
217
202
218
self .assertEqual (
203
- tarantool .response .Response (header , body ),
219
+ tarantool .response .Response (ConnectionMock ( tarantool . STR ), header , body ),
204
220
[(b"\x01 \x00 \x00 \x00 " , b"1111111111" ),
205
221
(b"\x02 \x00 \x00 \x00 " , b"2222222222" ),
206
222
(b"\x03 \x00 \x00 \x00 " , b"LLL" , b"MMM" , b"NNN" )],
@@ -213,7 +229,7 @@ def test__init_attrs(self):
213
229
214
230
header = from_hex ("0d00000014000000 11223344" )
215
231
body = from_hex ("00000000010000000400000002000000014b015a" )
216
- r = tarantool .response .Response (header , body )
232
+ r = tarantool .response .Response (ConnectionMock ( tarantool . STR ), header , body )
217
233
218
234
self .assertEqual (r .return_code , 0 , "Check return_code property" )
219
235
self .assertIsNone (r .return_message , "Check return_message property" )
0 commit comments