Skip to content

Commit 2428af1

Browse files
committedMar 25, 2015
Add requirements file, remove obsolete response code and update tests
1 parent a7ead2f commit 2428af1

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed
 

‎.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ before_script:
1919
- sudo apt-get update
2020

2121
script:
22-
- sudo apt-get -y install tarantool python-yaml msgpack-python
22+
- sudo apt-get -y install tarantool
23+
- pip install -r requirements.txt
2324
- python setup.py test

‎requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
msgpack-python>=0.4.0
2+
pyyaml>=3.10

‎tarantool/response.py

-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ def completion_status(self):
8282
There are only three completion status codes in use:
8383
* ``0`` -- "success"; the only possible :attr:`return_code` with
8484
this status is ``0``
85-
* ``1`` -- "try again"; an indicator of an intermittent error.
86-
This status is handled automatically by this module.
8785
* ``2`` -- "error"; in this case :attr:`return_code` holds
8886
the actual error.
8987
'''

‎tests/suites/test_dml.py

+28-29
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def setUpClass(self):
2424
def test_00_00_authenticate(self):
2525
self.assertIsNone(self.srv.admin("box.schema.user.create('test', { password = 'test' })"))
2626
self.assertIsNone(self.srv.admin("box.schema.user.grant('test', 'execute,read,write', 'universe')"))
27-
self.assertEqual(self.con.authenticate('test', 'test'), [])
27+
self.assertEqual(self.con.authenticate('test', 'test')._data, None)
2828

2929
def test_00_01_space_created(self):
3030
# Check that space is created in setUpClass
@@ -35,23 +35,22 @@ def test_00_02_fill_space(self):
3535
for i in xrange(1, 500):
3636
self.assertEqual(
3737
self.con.insert('space_1', [i, i%5, 'tuple_'+str(i)])[0],
38-
(i, i%5, 'tuple_'+str(i))
38+
[i, i%5, 'tuple_'+str(i)]
3939
)
4040
def test_00_03_answer_repr(self):
4141
repr_str = \
42-
'''---
43-
- [1, 1, 'tuple_1']
44-
...'''
42+
'''- [1, 1, tuple_1]
43+
'''
4544
self.assertEqual(repr(self.con.select('space_1', 1)), repr_str)
4645

4746
def test_02_select(self):
4847
# Check that select with different keys are Ok. (With and without index names)
49-
self.assertEqual(self.con.select('space_1', 20), [(20, 0, 'tuple_20')])
50-
self.assertEqual(self.con.select('space_1', [21]), [(21, 1, 'tuple_21')])
51-
self.assertEqual(self.con.select('space_1', [22], index='primary'), [(22, 2, 'tuple_22')])
52-
self.assertEqual(self.con.select('space_1', [23], index='primary'), [(23, 3, 'tuple_23')])
48+
self.assertEqual(self.con.select('space_1', 20), [[20, 0, 'tuple_20']])
49+
self.assertEqual(self.con.select('space_1', [21]), [[21, 1, 'tuple_21']])
50+
self.assertEqual(self.con.select('space_1', [22], index='primary'), [[22, 2, 'tuple_22']])
51+
self.assertEqual(self.con.select('space_1', [23], index='primary'), [[23, 3, 'tuple_23']])
5352
# Check that Offset and Limit args are working fine.
54-
self.assertEqual(self.con.select('space_1', [20], index='primary', limit=1), [(20, 0, 'tuple_20')])
53+
self.assertEqual(self.con.select('space_1', [20], index='primary', limit=1), [[20, 0, 'tuple_20']])
5554
# With other indexes too
5655
self.assertEqual(
5756
sorted(
@@ -63,14 +62,14 @@ def test_02_select(self):
6362
sorted(
6463
self.con.select('space_1', [0], index='secondary', offset=3, limit=1),
6564
key = lambda x: x[0]),
66-
[(110, 0, 'tuple_110')]
65+
[[110, 0, 'tuple_110']]
6766
)
6867
self.assertEqual(
6968
sorted(
7069
self.con.select('space_1', [0], index='secondary', offset=3, limit=2),
7170
key = lambda x: x[0]),
72-
[(110, 0, 'tuple_110'),\
73-
(115, 0, 'tuple_115')]
71+
[[110, 0, 'tuple_110'],\
72+
[115, 0, 'tuple_115']]
7473
)
7574

7675
select_req = self.con.select('space_1', [0], index='secondary')
@@ -90,23 +89,23 @@ def test_02_select(self):
9089

9190
def test_03_delete(self):
9291
# Check that delete works fine
93-
self.assertEqual(self.con.delete('space_1', 20), [(20, 0, 'tuple_20')])
92+
self.assertEqual(self.con.delete('space_1', 20), [[20, 0, 'tuple_20']])
9493
self.assertEqual(self.con.delete('space_1', [20]), [])
9594
self.assertEqual(self.con.select('space_1', [20], index='primary'), [])
9695
# Check that <index_id> field has no meaning, yet.
9796
with self.assertRaisesRegexp(tarantool.DatabaseError,
9897
'(19, .*)'):
9998
self.con.delete('space_1', [1, 'tuple_21'])
100-
self.assertEqual(self.con.select('space_1', [21], index='primary'), [(21, 1, 'tuple_21')])
99+
self.assertEqual(self.con.select('space_1', [21], index='primary'), [[21, 1, 'tuple_21']])
101100

102101
def test_04_replace(self):
103102
# Check replace that is Ok.
104-
self.assertEqual(self.con.replace('space_1', [2, 2, 'tuple_3']), [(2, 2, 'tuple_3')])
105-
self.assertEqual(self.con.select('space_1', 2), [(2, 2, 'tuple_3')])
103+
self.assertEqual(self.con.replace('space_1', [2, 2, 'tuple_3']), [[2, 2, 'tuple_3']])
104+
self.assertEqual(self.con.select('space_1', 2), [[2, 2, 'tuple_3']])
106105
# Check replace that isn't Ok.
107106
with self.assertRaisesRegexp(tarantool.DatabaseError,
108107
'(39, .*)'):
109-
self.assertEqual(self.con.replace('space_1', [2, 2]), [(2, 2, 'tuple_2')])
108+
self.assertEqual(self.con.replace('space_1', [2, 2]), [[2, 2, 'tuple_2']])
110109

111110
def test_05_ping(self):
112111
# Simple ping test
@@ -117,22 +116,22 @@ def test_05_ping(self):
117116

118117
def test_06_update(self):
119118
self.assertEqual(self.con.update('space_1', (2,), [('+', 1, 3)]),
120-
[(2, 5, 'tuple_3')])
119+
[[2, 5, 'tuple_3']])
121120
self.assertEqual(self.con.update('space_1', (2,), [('-', 1, 3)]),
122-
[(2, 2, 'tuple_3')])
121+
[[2, 2, 'tuple_3']])
123122
self.assertEqual(self.con.update('space_1', (2,), [(':', 2, 3, 2, 'lalal')]),
124-
[(2, 2, 'tuplalal_3')])
123+
[[2, 2, 'tuplalal_3']])
125124
self.assertEqual(self.con.update('space_1', (2,), [('!', 2, '1')]),
126-
[(2, 2, '1', 'tuplalal_3')])
125+
[[2, 2, '1', 'tuplalal_3']])
127126
self.assertEqual(self.con.update('space_1', (2,), [('!', 2, 'oingo, boingo')]),
128-
[(2, 2, 'oingo, boingo', '1', 'tuplalal_3')])
127+
[[2, 2, 'oingo, boingo', '1', 'tuplalal_3']])
129128
self.assertEqual(self.con.update('space_1', (2,), [('#', 2, 2)]),
130-
[(2, 2, 'tuplalal_3')])
129+
[[2, 2, 'tuplalal_3']])
131130

132131
def test_07_call(self):
133-
self.assertEqual(self.con.call('json.decode', '[123, 234, 345]'), [(123, 234, 345)])
134-
self.assertEqual(self.con.call('json.decode', ['[123, 234, 345]']), [(123, 234, 345)])
135-
self.assertEqual(self.con.call('json.decode', ('[123, 234, 345]',)), [(123, 234, 345)])
132+
self.assertEqual(self.con.call('json.decode', '[123, 234, 345]'), [[123, 234, 345]])
133+
self.assertEqual(self.con.call('json.decode', ['[123, 234, 345]']), [[123, 234, 345]])
134+
self.assertEqual(self.con.call('json.decode', ('[123, 234, 345]',)), [[123, 234, 345]])
136135
with self.assertRaisesRegexp(tarantool.DatabaseError,
137136
'(32, .*)'):
138137
self.con.call('json.decode')
@@ -159,8 +158,8 @@ def test_07_call(self):
159158
# '(12345, \'lol, error\')'):
160159
# self.con.call('box.error', [12345, 'lol, error'])
161160

162-
self.assertEqual(self.con.call('box.tuple.new', [1, 2, 3, 'fld_1']), [(1, 2, 3, 'fld_1')])
163-
self.assertEqual(self.con.call('box.tuple.new', 'fld_1'), [('fld_1',)])
161+
self.assertEqual(self.con.call('box.tuple.new', [1, 2, 3, 'fld_1']), [[1, 2, 3, 'fld_1']])
162+
self.assertEqual(self.con.call('box.tuple.new', 'fld_1'), [['fld_1']])
164163

165164
@classmethod
166165
def tearDownClass(self):

‎tests/suites/test_schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_00_authenticate(self):
1919
self.assertIsNone(self.srv.admin("box.schema.user.create('test', { password = 'test' })"))
2020
self.assertIsNone(self.srv.admin("box.schema.user.grant('test', 'read,write', 'space', '_space')"))
2121
self.assertIsNone(self.srv.admin("box.schema.user.grant('test', 'read,write', 'space', '_index')"))
22-
self.assertEqual(self.con.authenticate('test', 'test'), [])
22+
self.assertEqual(self.con.authenticate('test', 'test')._data, None)
2323

2424
def test_01_space_bad(self):
2525
with self.assertRaisesRegexp(tarantool.SchemaError,

0 commit comments

Comments
 (0)
Please sign in to comment.