Test against newer packages and fix test issues

- Loosen regex. Newer presto has "line 1:1: " in the beginning of the message
- Fix <> vs ()
- add sleep hack
- fix skip on insert test
This commit is contained in:
Jing Wang 2016-03-21 13:18:59 -07:00
Родитель a2866ab1e5
Коммит 9a93f85538
4 изменённых файлов: 18 добавлений и 11 удалений

Просмотреть файл

@ -2,9 +2,9 @@ sudo: required
language: python
env:
# newest everything
- CDH=cdh5 PRESTO=0.118 SQLALCHEMY=1.0.8
# stale stuff we're still actively using
- CDH=cdh4 PRESTO=0.97 SQLALCHEMY=0.5.8
- CDH=cdh5 PRESTO=0.142 SQLALCHEMY=1.0.12
# stale stuff we're still using / supporting
- CDH=cdh5 PRESTO=0.118 SQLALCHEMY=0.5.8
# every version of sqlalchemy with special code
- CDH=cdh4 PRESTO=0.118 SQLALCHEMY=0.5.8
- CDH=cdh4 PRESTO=0.118 SQLALCHEMY=0.6.9
@ -20,5 +20,6 @@ install:
- pip install -e .
- pip install sqlalchemy==$SQLALCHEMY
- pip install -r dev_requirements.txt
script: py.test
# sleep so Presto has time to start up. Otherwise we might get 'No nodes available to run query'
script: sleep 10 && py.test
after_success: codecov

Просмотреть файл

@ -98,8 +98,8 @@ class PrestoDialect(default.DefaultDialect):
# presto.DatabaseError here.
# Does the table exist?
msg = e.message.get('message') if isinstance(e.message, dict) else None
regex = r"^Table\ \'.*{}\'\ does\ not\ exist$".format(re.escape(table_name))
if msg and re.match(regex, msg):
regex = r"Table\ \'.*{}\'\ does\ not\ exist".format(re.escape(table_name))
if msg and re.search(regex, msg):
raise exc.NoSuchTableError(table_name)
else:
raise

Просмотреть файл

@ -30,8 +30,13 @@ class TestPresto(unittest.TestCase, DBAPITestCase):
@with_cursor
def test_complex(self, cursor):
cursor.execute('SELECT * FROM one_row_complex')
# TODO delete this code after dropping test support for older presto
# old presto uses <>, while new presto uses ()
description = []
for row in cursor.description:
description.append((row[0], row[1].replace('<', '(').replace('>', ')')) + row[2:])
# TODO Presto drops the union and decimal fields
self.assertEqual(cursor.description, [
self.assertEqual(description, [
('boolean', 'boolean', None, None, None, None, True),
('tinyint', 'bigint', None, None, None, None, True),
('smallint', 'bigint', None, None, None, None, True),
@ -42,9 +47,9 @@ class TestPresto(unittest.TestCase, DBAPITestCase):
('string', 'varchar', None, None, None, None, True),
('timestamp', 'timestamp', None, None, None, None, True),
('binary', 'varbinary', None, None, None, None, True),
('array', 'array<bigint>', None, None, None, None, True),
('map', 'map<bigint,bigint>', None, None, None, None, True),
('struct', "row<bigint,bigint>('a','b')", None, None, None, None, True),
('array', 'array(bigint)', None, None, None, None, True),
('map', 'map(bigint,bigint)', None, None, None, None, True),
('struct', "row(bigint,bigint)('a','b')", None, None, None, None, True),
#('union', 'varchar', None, None, None, None, True),
#('decimal', 'double', None, None, None, None, True),
])

Просмотреть файл

@ -146,7 +146,8 @@ class TestSqlAlchemyHive(unittest.TestCase, SqlAlchemyTestCase):
expected = [(1,)]
self.assertEqual(result, expected)
@unittest.skipIf(os.environ.get('CDH') == 'cdh4', "not supported on hive 0.10")
@unittest.skipIf(os.environ.get('CDH') == 'cdh4' or os.environ.get('SQLALCHEMY') == '0.5.8',
"not supported on hive 0.10 or old sqlalchemy")
@with_engine_connection
def test_insert_values(self, engine, connection):
table = Table('insert_test', MetaData(bind=engine),