Skip to content

Commit

Permalink
Add test to ensure redis integration disabled unless installed
Browse files Browse the repository at this point in the history
  • Loading branch information
szokeasaurusrex committed Nov 13, 2023
1 parent cb7299a commit 069b6e9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from sentry_sdk import (
configure_scope,
continue_trace,
Expand All @@ -7,12 +9,20 @@
start_transaction,
)
from sentry_sdk.hub import Hub
from sentry_sdk.integrations.redis import RedisIntegration

try:
from unittest import mock # python 3.3 and above
except ImportError:
import mock # python < 3.3

try:
import redis # noqa: F401
except ImportError:
REDIS_INSTALLED = False
else:
REDIS_INSTALLED = True


def test_get_current_span():
fake_hub = mock.MagicMock()
Expand Down Expand Up @@ -113,3 +123,10 @@ def test_continue_trace(sentry_init):
assert propagation_context["dynamic_sampling_context"] == {
"trace_id": "566e3688a61d4bc888951642d6f14a19"
}


@pytest.mark.skipif(REDIS_INSTALLED, reason="skipping because redis is installed")
def test_redis_disabled_when_not_installed(sentry_init):
sentry_init()

assert Hub.current.get_integration(RedisIntegration) is None

0 comments on commit 069b6e9

Please sign in to comment.