Beispiel #1
0
def test_db_check_dbapi_error(mocker, db):
    exception = DBAPIError.instance("", [], Exception(), Exception)
    engine_connect = mocker.patch.object(db.engine, "connect")
    engine_connect.side_effect = exception
    errors = checks.check_database_connected(db)
    assert len(errors) == 1
    assert errors[0].id == health.ERROR_DB_API_EXCEPTION
Beispiel #2
0
def test_db_check_success(db):
    errors = checks.check_database_connected(db)
    assert errors == []
Beispiel #3
0
def test_db_check_sqlalchemy_error(mocker, db):
    engine_connect = mocker.patch.object(db.engine, "connect")
    engine_connect.side_effect = SQLAlchemyError
    errors = checks.check_database_connected(db)
    assert len(errors) == 1
    assert errors[0].id == health.ERROR_SQLALCHEMY_EXCEPTION