File tree Expand file tree Collapse file tree 3 files changed +45
-2
lines changed
tests/integrations/rediscluster Expand file tree Collapse file tree 3 files changed +45
-2
lines changed Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ pytest .importorskip ("rediscluster" )
Original file line number Diff line number Diff line change
1
+ import pytest
2
+ from sentry_sdk import capture_message
3
+ from sentry_sdk .integrations .redis import RedisIntegration
4
+
5
+ import rediscluster
6
+
7
+ rediscluster_classes = [rediscluster .RedisCluster ]
8
+
9
+ if hasattr (rediscluster , "StrictRedisCluster" ):
10
+ rediscluster_classes .append (rediscluster .StrictRedisCluster )
11
+
12
+
13
+ @pytest .fixture (scope = "module" , autouse = True )
14
+ def monkeypatch_rediscluster_classes ():
15
+ for cls in rediscluster_classes :
16
+ cls .execute_command = lambda * _ , ** __ : None
17
+
18
+
19
+ @pytest .mark .parametrize ("rediscluster_cls" , rediscluster_classes )
20
+ def test_rediscluster_basic (rediscluster_cls , sentry_init , capture_events ):
21
+ sentry_init (integrations = [RedisIntegration ()])
22
+ events = capture_events ()
23
+
24
+ rc = rediscluster_cls (connection_pool = True )
25
+ rc .get ("foobar" )
26
+ capture_message ("hi" )
27
+
28
+ (event ,) = events
29
+ (crumb ,) = event ["breadcrumbs" ]
30
+
31
+ assert crumb == {
32
+ "category" : "redis" ,
33
+ "message" : "GET 'foobar'" ,
34
+ "data" : {"redis.key" : "foobar" , "redis.command" : "GET" },
35
+ "timestamp" : crumb ["timestamp" ],
36
+ "type" : "redis" ,
37
+ }
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ envlist =
62
62
{py2.7,py3.8}-requests
63
63
64
64
{py2.7,py3.7,py3.8}-redis
65
+ {py2.7,py3.7,py3.8}-rediscluster-{1,2}
65
66
66
67
py{3.7,3.8}-asgi
67
68
@@ -166,8 +167,9 @@ deps =
166
167
trytond-4.6: trytond>=4.6,<4.7
167
168
168
169
redis: fakeredis
169
- # https://github.com/jamesls/fakeredis/issues/245
170
- redis: redis<3.2.2
170
+
171
+ rediscluster-1: redis-py-cluster>=1.0.0,<2.0.0
172
+ rediscluster-2: redis-py-cluster>=2.0.0,<3.0.0
171
173
172
174
asgi: starlette
173
175
asgi: requests
@@ -199,6 +201,7 @@ setenv =
199
201
tornado: TESTPATH =tests/integrations/tornado
200
202
trytond: TESTPATH =tests/integrations/trytond
201
203
redis: TESTPATH =tests/integrations/redis
204
+ rediscluster: TESTPATH =tests/integrations/rediscluster
202
205
asgi: TESTPATH =tests/integrations/asgi
203
206
sqlalchemy: TESTPATH =tests/integrations/sqlalchemy
204
207
spark: TESTPATH =tests/integrations/spark
You can’t perform that action at this time.
0 commit comments