Skip to content

Commit d015d96

Browse files
committed
redis client for tests [redis_client_for_tests]
1 parent d1c70f8 commit d015d96

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/e2e/redis_client.py

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

0 commit comments

Comments
 (0)