Created
July 1, 2019 23:34
-
-
Save nkthiebaut/6681750a5d13765dfa1c584de87dfebb to your computer and use it in GitHub Desktop.
Test Rollbar configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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