Skip to content

Instantly share code, notes, and snippets.

@nkthiebaut
Created July 1, 2019 23:34
Show Gist options
  • Save nkthiebaut/6681750a5d13765dfa1c584de87dfebb to your computer and use it in GitHub Desktop.
Save nkthiebaut/6681750a5d13765dfa1c584de87dfebb to your computer and use it in GitHub Desktop.
Test Rollbar configuration
from unittest.mock import patch
import rollbar
@patch("rollbar.log.exception")
def test_rollbar_connection(log_exception_mock):
"""
Test sending an exception to Rollbar. The Rollbar Python SDK reports requests
errors through exceptions logs. Here we check that the exception function
of the logging module has NOT been called after reporting an exception to Rollbar.
The result can be checked on Rollbar's side.
"""
rollbar_token = os.environ.get("ROLLBAR_TOKEN")
rollbar.init(rollbar_token)
rollbar.report_exc_info((None, Exception("Example exception"), None))
rollbar.wait()
log_exception_mock.assert_not_called()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment