Skip to content

Commit c69661d

Browse files
committed
redis client for tests [redis_client_for_tests]
1 parent f99ab96 commit c69661d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/e2e/redis_client.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import json
2+
import redis
3+
4+
from allocation import config
5+
6+
r = redis.Redis(**config.get_redis_host_and_port())
7+
8+
9+
def subscribe_to(channel):
10+
pubsub = r.pubsub()
11+
pubsub.subscribe(channel)
12+
confirmation = pubsub.get_message(timeout=3)
13+
assert confirmation["type"] == "subscribe"
14+
return pubsub
15+
16+
17+
def publish_message(channel, message):
18+
r.publish(channel, json.dumps(message))

0 commit comments

Comments
 (0)