1111from_hex = lambda x : binascii .unhexlify ('' .join (x .split ()))
1212to_hex = lambda x : binascii .hexlify (x )
1313
14-
1514import 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+ })
1733
1834class field (unittest .TestCase ):
1935 '''
@@ -168,7 +184,7 @@ def test__init_single(self):
168184 "04 01000000" + "05 4a4b4c4d4e" )
169185
170186 self .assertEqual (
171- tarantool .response .Response (header , body ),
187+ tarantool .response .Response (ConnectionMock ( tarantool . STR ), header , body ),
172188 [(b"\x01 \x00 \x00 \x00 " , b"JKLMN" )],
173189 "Create Response instance: single record"
174190 )
@@ -200,7 +216,7 @@ def test__init_multiple(self):
200216 )
201217
202218 self .assertEqual (
203- tarantool .response .Response (header , body ),
219+ tarantool .response .Response (ConnectionMock ( tarantool . STR ), header , body ),
204220 [(b"\x01 \x00 \x00 \x00 " , b"1111111111" ),
205221 (b"\x02 \x00 \x00 \x00 " , b"2222222222" ),
206222 (b"\x03 \x00 \x00 \x00 " , b"LLL" , b"MMM" , b"NNN" )],
@@ -213,7 +229,7 @@ def test__init_attrs(self):
213229
214230 header = from_hex ("0d00000014000000 11223344" )
215231 body = from_hex ("00000000010000000400000002000000014b015a" )
216- r = tarantool .response .Response (header , body )
232+ r = tarantool .response .Response (ConnectionMock ( tarantool . STR ), header , body )
217233
218234 self .assertEqual (r .return_code , 0 , "Check return_code property" )
219235 self .assertIsNone (r .return_message , "Check return_message property" )
0 commit comments