Skip to content

Commit 771a0bd

Browse files
committed
Fix for update. Added tests. closes gh-38
1 parent 7ba5ab6 commit 771a0bd

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/MANIFEST
77
*.snap
88
sophia
9+
*.egg-info

tarantool/connection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def check(): # Check that connection is alive
208208

209209
last_errno = check()
210210
if self.connected and last_errno == errno.EAGAIN:
211-
return
211+
return
212212

213213
attempt = 0
214214
last_errno = 0
@@ -352,6 +352,8 @@ def update(self, space_name, key, op_list, **kwargs):
352352
353353
:param space_name: space number or name to update a record
354354
:type space_name: int or str
355+
:param index: index number or name to update a record
356+
:type index: int or str
355357
:param key: key that identifies a record
356358
:type key: int or str
357359
:param op_list: list of operations. Each operation
@@ -361,7 +363,7 @@ def update(self, space_name, key, op_list, **kwargs):
361363
362364
:rtype: `Response` instance
363365
'''
364-
index = kwargs.get("index", 0)
366+
index_name = kwargs.get("index", 0)
365367

366368
key = check_key(key)
367369
if isinstance(space_name, basestring):

tests/suites/test_dml.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,18 @@ def test_05_ping(self):
116116
self.assertEqual(self.con.ping(notime=True), "Success")
117117

118118
def test_06_update(self):
119-
pass
119+
self.assertEqual(self.con.update('space_1', (2,), [('+', 1, 3)]),
120+
[(2, 5, 'tuple_3')])
121+
self.assertEqual(self.con.update('space_1', (2,), [('-', 1, 3)]),
122+
[(2, 2, 'tuple_3')])
123+
self.assertEqual(self.con.update('space_1', (2,), [(':', 2, 3, 2, 'lalal')]),
124+
[(2, 2, 'tuplalal_3')])
125+
self.assertEqual(self.con.update('space_1', (2,), [('!', 2, '1')]),
126+
[(2, 2, '1', 'tuplalal_3')])
127+
self.assertEqual(self.con.update('space_1', (2,), [('!', 2, 'oingo, boingo')]),
128+
[(2, 2, 'oingo, boingo', '1', 'tuplalal_3')])
129+
self.assertEqual(self.con.update('space_1', (2,), [('#', 2, 2)]),
130+
[(2, 2, 'tuplalal_3')])
120131

121132
def test_07_call(self):
122133
self.assertEqual(self.con.call('json.decode', '[123, 234, 345]'), [(123, 234, 345)])

0 commit comments

Comments
 (0)