-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import pytest | ||
|
||
pytest.importorskip("rediscluster") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pytest | ||
from sentry_sdk import capture_message | ||
import sentry_sdk.integrations | ||
from sentry_sdk.integrations.redis import RedisIntegration | ||
|
||
import rediscluster | ||
|
||
rediscluster_classes = ["RedisCluster"] | ||
|
||
if hasattr(rediscluster, "StrictRedisCluster"): | ||
rediscluster_classes.append("StrictRedisCluster") | ||
|
||
|
||
@pytest.mark.parametrize("clsname", rediscluster_classes) | ||
def test_rediscluster_basic(clsname, sentry_init, capture_events, monkeypatch): | ||
|
||
redis_cluster_cls = getattr(rediscluster, clsname) | ||
|
||
execute_command_calls = [] | ||
|
||
def execute_command(*args, **kwargs): | ||
execute_command_calls.append((args, kwargs)) | ||
|
||
monkeypatch.setattr( | ||
redis_cluster_cls, "execute_command", execute_command, | ||
) | ||
|
||
# should be done by the sentry_init fixture? | ||
sentry_sdk.integrations._installed_integrations = set() | ||
|
||
sentry_init(integrations=[RedisIntegration()]) | ||
events = capture_events() | ||
|
||
rc = redis_cluster_cls(connection_pool=True) | ||
rc.get("foobar") | ||
capture_message("hi") | ||
|
||
(event,) = events | ||
(crumb,) = event["breadcrumbs"] | ||
|
||
assert crumb == { | ||
"category": "redis", | ||
"message": "GET 'foobar'", | ||
"data": {"redis.key": "foobar", "redis.command": "GET"}, | ||
"timestamp": crumb["timestamp"], | ||
"type": "redis", | ||
} |
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