Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_connect(sqlitedb):
conn = connect(sqlitedb)
assert isinstance(conn, sqlite3.Connection)
assert os.path.isfile(sqlitedb.filename)
def test_bad_connect(tmpdir):
# Attemping to create file in non-existent directory should fail
try:
db_params = DbParams(dbtype='SQLITE', filename='/does/not/exist')
with pytest.raises(ETLHelperConnectionError):
connect(db_params)
finally:
# Restore permissions prior to cleanup
os.chmod(tmpdir, 0o666)
def test_connect():
conn = connect(ORADB, 'TEST_ORACLE_PASSWORD')
assert isinstance(conn, cx_Oracle.Connection)
def testdb_conn():
"""Get connection to test MS SQL database."""
with connect(ORADB, 'TEST_ORACLE_PASSWORD', encoding="UTF-8",
nencoding="UTF-8") as conn:
yield conn
def testdb_conn(sqlitedb):
"""Get connection to test SQLite database."""
with connect(sqlitedb) as conn:
yield conn
def test_connect_wrong_password(monkeypatch):
monkeypatch.setitem(os.environ, 'TEST_ORACLE_PASSWORD', 'bad_password')
with pytest.raises(ETLHelperConnectionError):
connect(ORADB, 'TEST_ORACLE_PASSWORD')