Skip to content

Commit

Permalink
Fix tests following merge
Browse files Browse the repository at this point in the history
  • Loading branch information
volcan01010 committed Oct 11, 2019
1 parent f630af9 commit 764bc16
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
7 changes: 7 additions & 0 deletions bin/run_tests_for_developer.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#! /bin/sh
echo "Building container"
docker build \
--build-arg INSTANT_CLIENT_ZIP=${INSTANT_CLIENT_ZIP} \
-t etlhelper-test-runner . || exit 1

echo "Flake8 checks"
docker run \
etlhelper-test-runner flake8 etlhelper test || exit 1

echo "Unit and integration tests"
docker run \
-e TEST_PG_PASSWORD="${TEST_PG_PASSWORD}" \
-e TEST_ORACLE_DBTYPE="${TEST_ORACLE_DBTYPE}" \
Expand Down
16 changes: 9 additions & 7 deletions test/integration/db/test_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ def test_connect(sqlitedb):


@pytest.mark.skipif(sys.platform != 'linux', reason='Requires Linux OS')
def test_bad_connect():
if os.getenv('USER') == 'root':
# Don't run for root user, but don't mark as skipped either
return
db_params = DbParams(dbtype='SQLITE', filename='/cannot_write_to_root')
with pytest.raises(ETLHelperConnectionError):
connect(db_params)
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_bad_select(testdb_conn):
Expand Down
9 changes: 3 additions & 6 deletions test/unit/test_db_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@
from etlhelper.db_helper_factory import DB_HELPER_FACTORY
from etlhelper.db_helpers import (
OracleDbHelper,
SqlServerDbHelper,
PostgresDbHelper,
SQLiteDbHelper
)

# pylint: disable=missing-docstring

ORACLEDB = DbParams(dbtype='ORACLE', host='server', port='1521',
dbname='testdb', username='testuser')
dbname='testdb', user='testuser')

MSSQLDB = DbParams(dbtype='MSSQL', host='server', port='1521', dbname='testdb',
username='testuser', odbc_driver='test driver')
user='testuser', odbc_driver='test driver')

POSTGRESDB = DbParams(dbtype='PG', host='server', port='1521', dbname='testdb',
username='testuser', odbc_driver='test driver')
user='testuser', odbc_driver='test driver')

SQLITEDB = DbParams(dbtype='SQLITE', filename='/myfile.db')

Expand Down

0 comments on commit 764bc16

Please sign in to comment.