"""Test helpers module.""" from raven import base as sentry_base from sqlalchemy import exc from owsmysql.utils import db_helpers def test_wrap_errors(mocker): """Check that wrap errors works.""" @db_helpers.wrap_errors def handler(error): if error: raise exc.SQLAlchemyError('foo') mock = mocker.patch.object(sentry_base, 'Raven') result = handler(True) # pylint: disable=assignment-from-no-return assert mock.captureException.called assert result.status == 500 assert handler(False) is None