Skip to content

Commit

Permalink
fix & simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-schick committed Jan 31, 2023
1 parent 2ec79b4 commit 501f56a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 39 deletions.
15 changes: 15 additions & 0 deletions tests/db_test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,18 @@ def _test_sqlalchemy(db):
# the SELECT of a scalar value without a table is
# appropriately formatted for the backend
assert conn.scalar(select(1)) == 1

def _test_connect(db):
connection = db.connect()
cursor = connection.cursor()
try:
cursor.execute('SELECT 1')
row = cursor.fetchone()
assert row[0] == 1
connection.commit()
except Exception as e:
connection.rollback()
raise e
finally:
cursor.close()
connection.close()
15 changes: 2 additions & 13 deletions tests/mssql/test_mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,8 @@ def test_mssql_connect(mssql_db):
"""
A simple test to check if the connect API works.
"""
connection = MSSQL_DB.connect()
cursor = connection.cursor()
try:
cursor.execute('SELECT 1')
row = cursor.fetchone()
assert row[0] == 1
connection.commit()
except Exception as e:
connection.rollback()
raise e
finally:
cursor.close()
connection.close()
from ..db_test_helper import _test_connect
_test_connect(mssql_db)



Expand Down
15 changes: 2 additions & 13 deletions tests/postgres/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,5 @@ def test_postgres_connect(postgres_db):
"""
A simple test to check if the connect API works.
"""
connection = POSTGRES_DB.connect()
cursor = connection.cursor()
try:
cursor.execute('SELECT 1')
row = cursor.fetchone()
assert row[0] == 1
connection.commit()
except Exception as e:
connection.rollback()
raise e
finally:
cursor.close()
connection.close()
from ..db_test_helper import _test_connect
_test_connect(postgres_db)
15 changes: 2 additions & 13 deletions tests/test_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,5 @@ def test_databricks_connect():
"""
A simple test to check if the connect API works.
"""
connection = DATABRICKS_DB.connect()
cursor = connection.cursor()
try:
cursor.execute('SELECT 1')
row = cursor.fetchone()
assert row[0] == 1
connection.commit()
except Exception as e:
connection.rollback()
raise e
finally:
cursor.close()
connection.close()
from .db_test_helper import _test_connect
_test_connect(DATABRICKS_DB)

0 comments on commit 501f56a

Please sign in to comment.