Skip to content

Commit 051ca05

Browse files
committed
Skip SQL tests if tarantool version < 2.0.0
Problem: all SQL-related tests fail with the following error if tarantool < 2.0.0 is used: tarantool.error.DatabaseError: (48, 'Unknown request type 11') Tarantool supports SQL-related stuff only since the 2.0.0 version. So this patch adds a special decorator that will skip the test if tarantool version < 2.0.0 is used.
1 parent 6140342 commit 051ca05

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

test/suites/lib/skip.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import functools
2+
import pkg_resources
3+
4+
SQL_SUPPORT_TNT_VERSION = '2.0.0'
5+
6+
7+
def skip_or_run_sql_test(func):
8+
@functools.wraps(func)
9+
def wrapper(self, *args, **kwargs):
10+
tnt_version = pkg_resources.parse_version(self.tnt_version)
11+
sql_support_tnt_version = pkg_resources.parse_version(
12+
SQL_SUPPORT_TNT_VERSION
13+
)
14+
15+
if tnt_version < sql_support_tnt_version:
16+
self.skipTest(
17+
'Tarantool %s does not support SQL' % self.tnt_version
18+
)
19+
else:
20+
func(self, *args, **kwargs)
21+
22+
return wrapper

test/suites/test_dbapi.py

+45
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import tarantool
1111
from tarantool import dbapi
1212
from .lib.tarantool_server import TarantoolServer
13+
from .lib.skip import skip_or_run_sql_test
1314

1415

1516
class TestSuite_DBAPI(dbapi20.DatabaseAPI20Test):
@@ -33,6 +34,9 @@ def setUpClass(self):
3334
self.connect_kw_args = dict(
3435
host=self.srv.host,
3536
port=self.srv.args['primary'])
37+
self.tnt_version = '.'.join(
38+
self.srv.admin('box.info.version')[0].split('-')[0].split('.')[:3]
39+
)
3640

3741
def setUp(self):
3842
# prevent a remote tarantool from clean our session
@@ -50,6 +54,47 @@ def tearDownClass(self):
5054
self.srv.stop()
5155
self.srv.clean()
5256

57+
@skip_or_run_sql_test
58+
def test_None(self):
59+
super(TestSuite_DBAPI, self).test_None()
60+
61+
@skip_or_run_sql_test
62+
def test_cursor_isolation(self):
63+
super(TestSuite_DBAPI, self).test_cursor_isolation()
64+
65+
@skip_or_run_sql_test
66+
def test_execute(self):
67+
super(TestSuite_DBAPI, self).test_execute()
68+
69+
@skip_or_run_sql_test
70+
def test_executemany(self):
71+
super(TestSuite_DBAPI, self).test_executemany()
72+
73+
@skip_or_run_sql_test
74+
def test_fetchall(self):
75+
super(TestSuite_DBAPI, self).test_fetchall()
76+
77+
@skip_or_run_sql_test
78+
def test_fetchmany(self):
79+
super(TestSuite_DBAPI, self).test_fetchmany()
80+
81+
@skip_or_run_sql_test
82+
def test_fetchone(self):
83+
super(TestSuite_DBAPI, self).test_fetchone()
84+
85+
@skip_or_run_sql_test
86+
def test_mixedfetch(self):
87+
super(TestSuite_DBAPI, self).test_mixedfetch()
88+
89+
@skip_or_run_sql_test
90+
def test_setinputsizes(self):
91+
super(TestSuite_DBAPI, self).test_setinputsizes()
92+
93+
@skip_or_run_sql_test
94+
def test_setoutputsize_basic(self):
95+
super(TestSuite_DBAPI, self).test_setoutputsize_basic()
96+
97+
@skip_or_run_sql_test
5398
def test_rowcount(self):
5499
con = self._connect()
55100
try:

test/suites/test_execute.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77

88
import tarantool
99
from .lib.tarantool_server import TarantoolServer
10+
from .lib.skip import skip_or_run_sql_test
1011

1112

1213
class TestSuite_Execute(unittest.TestCase):
1314
ddl = 'create table %s (id INTEGER PRIMARY KEY AUTOINCREMENT, ' \
14-
'name varchar(20))'
15+
'name varchar(20))'
1516

1617
dml_params = [
1718
{'id': None, 'name': 'Michael'},
@@ -29,6 +30,9 @@ def setUpClass(self):
2930
self.srv.script = 'test/suites/box.lua'
3031
self.srv.start()
3132
self.con = tarantool.Connection(self.srv.host, self.srv.args['primary'])
33+
self.tnt_version = '.'.join(
34+
self.srv.admin('box.info.version')[0].split('-')[0].split('.')[:3]
35+
)
3236

3337
def setUp(self):
3438
# prevent a remote tarantool from clean our session
@@ -54,6 +58,7 @@ def _populate_data(self, table_name):
5458
def _create_table(self, table_name):
5559
return self.con.execute(self.ddl % table_name)
5660

61+
@skip_or_run_sql_test
5762
def test_dml_response(self):
5863
table_name = 'foo'
5964
response = self._create_table(table_name)
@@ -75,6 +80,7 @@ def test_dml_response(self):
7580
self.assertEqual(response.affected_row_count, 2)
7681
self.assertEqual(response.data, None)
7782

83+
@skip_or_run_sql_test
7884
def test_dql_response(self):
7985
table_name = 'bar'
8086
self._create_table(table_name)

0 commit comments

Comments
 (0)