44import yaml
55import unittest
66import tarantool
7+
78from .lib .tarantool_server import TarantoolServer
89
910class TestSuite_Request (unittest .TestCase ):
@@ -17,15 +18,36 @@ def setUpClass(self):
1718 self .con = tarantool .Connection ('localhost' , self .srv .args ['primary' ])
1819 self .adm = self .srv .admin
1920 self .space_created = self .adm ("box.schema.create_space('space_1')" )
20- self .adm ("box.space['space_1']:create_index('primary', {type = 'tree', parts = {1, 'num'}, unique = true})" )
21- self .adm ("box.space['space_1']:create_index('secondary', {type = 'tree', parts = {2, 'num', 3, 'str'}, unique = false})" )
21+ self .adm ("""
22+ box.space['space_1']:create_index('primary', {
23+ type = 'tree',
24+ parts = {1, 'num'},
25+ unique = true})
26+ """ .replace ('\n ' , ' ' ))
27+ self .adm ("""
28+ box.space['space_1']:create_index('secondary', {
29+ type = 'tree',
30+ parts = {2, 'num', 3, 'str'},
31+ unique = false})
32+ """ .replace ('\n ' , ' ' ))
33+ self .space_created = self .adm ("box.schema.create_space('space_2')" )
34+ self .adm ("""
35+ box.space['space_2']:create_index('primary', {
36+ type = 'hash',
37+ parts = {1, 'num'},
38+ unique = true})
39+ """ .replace ('\n ' , ' ' ))
2240 self .adm ("json = require('json')" )
2341 self .adm ("fiber = require('fiber')" )
2442 self .adm ("uuid = require('uuid')" )
2543
2644 def test_00_00_authenticate (self ):
27- self .assertIsNone (self .srv .admin ("box.schema.user.create('test', { password = 'test' })" ))
28- self .assertIsNone (self .srv .admin ("box.schema.user.grant('test', 'execute,read,write', 'universe')" ))
45+ self .assertIsNone (self .srv .admin ("""
46+ box.schema.user.create('test', { password = 'test' })
47+ """ ))
48+ self .assertIsNone (self .srv .admin ("""
49+ box.schema.user.grant('test', 'execute,read,write', 'universe')
50+ """ ))
2951 self .assertEqual (self .con .authenticate ('test' , 'test' )._data , None )
3052
3153 def test_00_01_space_created (self ):
@@ -40,9 +62,7 @@ def test_00_02_fill_space(self):
4062 [i , i % 5 , 'tuple_' + str (i )]
4163 )
4264 def test_00_03_answer_repr (self ):
43- repr_str = \
44- '''- [1, 1, tuple_1]
45- '''
65+ repr_str = """- [1, 1, tuple_1]\n """
4666 self .assertEqual (repr (self .con .select ('space_1' , 1 )), repr_str )
4767
4868 def test_02_select (self ):
@@ -213,6 +233,17 @@ def test_10_space(self):
213233 [[400 , 0 , 'tuple_400' ]])
214234 self .assertEqual (space .delete ([900 ]), [[900 , 10 , 'foo' ]])
215235
236+ def test_11_select_all_hash (self ):
237+ space = self .con .space ('space_2' )
238+ cnt = 10
239+ for k in xrange (cnt ):
240+ space .insert ([k , 'lol' ])
241+ self .assertEqual (len (space .select (())), cnt )
242+ self .assertEqual (len (space .select ([])), cnt )
243+ self .assertEqual (len (space .select ()), cnt )
244+ with self .assertRaises (tarantool .error .DatabaseError ):
245+ space .select ((), iterator = tarantool .const .ITERATOR_EQ )
246+
216247 @classmethod
217248 def tearDownClass (self ):
218249 self .srv .stop ()
0 commit comments