Skip to content

Commit 3eb42d2

Browse files
committed
Added fix's for other tests, now tests result is OK
1 parent f20ca84 commit 3eb42d2

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

tests/tarantool/request.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
'''
44
Tests for tarantool.request module
55
'''
6-
76
import binascii
87
import unittest
98

10-
119
import tarantool.request
1210
from tarantool.schema import Schema
1311

14-
1512
class ConnectionMock(object):
1613
def __init__(self, default_type):
1714
self.schema = Schema({
@@ -29,7 +26,6 @@ def __init__(self, default_type):
2926
}
3027
})
3128

32-
3329
class RequestInsert(unittest.TestCase):
3430
def setUp(self):
3531
self.conn1 = ConnectionMock(tarantool.NUM)
@@ -49,7 +45,6 @@ def test__cast_to_bytes(self):
4945
binascii.unhexlify("0d0000001c0000000000000001000000000000000300000003414141044242424206434343434343")
5046
)
5147

52-
5348
class RequestDelete(unittest.TestCase):
5449
def setUp(self):
5550
self.conn1 = ConnectionMock(tarantool.NUM)

tests/tarantool/response.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,25 @@
1111
from_hex = lambda x: binascii.unhexlify(''.join(x.split()))
1212
to_hex = lambda x: binascii.hexlify(x)
1313

14-
1514
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+
})
1733

1834
class 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

Comments
 (0)