"""Tests for the Sentry Connector.""" from connectors import sentry # noqa def test_sentry_enabled(mocker): """Test sentry.sentry_client is setup when config.SENTRY is set.""" mock_raven_client = mocker.patch.object( sentry.raven, 'Client', return_value='sentry client') mock_config = mocker.patch.object(sentry, 'config') mock_config.SENTRY = 'SENTRY' sentry_client = sentry.get_client() assert sentry.sentry_client mock_raven_client.assert_called_with('SENTRY') assert sentry_client == 'sentry client' def test_sentry_disabled(mocker): """Test sentry.sentry_client initialized with dsn of None.""" mock_raven_client = mocker.patch.object( sentry.raven, 'Client', return_value='sentry client') mock_config = mocker.patch.object(sentry, 'config') mock_config.SENTRY = None sentry_client = sentry.get_client() # last call is None mock_raven_client.assert_called_with(None) # sentry_client is returned assert sentry_client == 'sentry client'