-
Notifications
You must be signed in to change notification settings - Fork 462
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
46 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,38 @@ | ||
import pytest | ||
from sentry_sdk import capture_message | ||
import sentry_sdk.integrations | ||
from sentry_sdk.integrations.redis import RedisIntegration | ||
|
||
import rediscluster | ||
|
||
rediscluster_classes = [rediscluster.RedisCluster] | ||
|
||
if hasattr(rediscluster, "StrictRedisCluster"): | ||
rediscluster_classes.append(rediscluster.StrictRedisCluster) | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def monkeypatch_rediscluster_classes(): | ||
for cls in rediscluster_classes: | ||
cls.execute_command = lambda *_, **__: None | ||
|
||
|
||
@pytest.mark.parametrize("rediscluster_cls", rediscluster_classes) | ||
def test_rediscluster_basic(rediscluster_cls, sentry_init, capture_events): | ||
sentry_init(integrations=[RedisIntegration()]) | ||
events = capture_events() | ||
|
||
rc = rediscluster_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