import pytest from etlhelper import ( DbParams, connect, copy_rows, copy_table_rows, execute, get_rows, load, ) from etlhelper.exceptions import (ETLHelperConnectionError, ETLHelperInsertError, ETLHelperQueryError) # Skip these tests if database is unreachable MSSQLDB = DbParams.from_environment(prefix='TEST_MSSQL_') if not MSSQLDB.is_reachable(): pytest.skip('MSSQL test database is unreachable', allow_module_level=True) # -- Tests here -- def test_connect(): conn = connect(MSSQLDB, 'TEST_MSSQL_PASSWORD') assert isinstance(conn, pyodbc.Connection) def test_connect_wrong_password(monkeypatch): monkeypatch.setitem(os.environ, 'TEST_MSSQL_PASSWORD', 'bad_password') with pytest.raises(ETLHelperConnectionError): connect(MSSQLDB, 'TEST_MSSQL_PASSWORD')
These currently run against internal BGS instance. """ # pylint: disable=unused-argument, missing-docstring from datetime import datetime, date import os from textwrap import dedent import cx_Oracle import pytest from etlhelper import connect, get_rows, copy_rows, DbParams from etlhelper.exceptions import ETLHelperConnectionError from test.conftest import db_is_unreachable # Skip these tests if database is unreachable ORADB = DbParams.from_environment(prefix='TEST_ORACLE_') if db_is_unreachable(ORADB.host, ORADB.port): pytest.skip('Oracle test database is unreachable', allow_module_level=True) # -- Tests here -- def test_connect(): conn = connect(ORADB, 'TEST_ORACLE_PASSWORD') assert isinstance(conn, cx_Oracle.Connection) def test_connect_wrong_password(monkeypatch): monkeypatch.setitem(os.environ, 'TEST_ORACLE_PASSWORD', 'bad_password') with pytest.raises(ETLHelperConnectionError): connect(ORADB, 'TEST_ORACLE_PASSWORD')