summaryrefslogtreecommitdiffstats
path: root/tests/cli_tests/test_cli_pubsub.py
blob: 956e105febc640b0046c61fa3f6821f2ef5a90a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def test_subscribe(cli, clean_redis):
    cli.sendline("subscribe foo")
    cli.expect("subscribe from")
    cli.expect("foo")
    cli.expect("1")

    clean_redis.publish("foo", "test message")
    cli.expect("from")
    cli.expect("foo")
    cli.expect("test message")

    # unsubscribe, send ctrl-c
    cli.send(chr(3))
    cli.expect("unsubscribe from")
    cli.expect("0")


def test_subscribe_in_raw_mode(raw_cli, clean_redis):
    raw_cli.sendline("subscribe foo")
    raw_cli.expect("subscribe\r")
    raw_cli.expect("foo\r")
    raw_cli.expect("1\r")

    clean_redis.publish("foo", "test message")
    raw_cli.expect("message\r")
    raw_cli.expect("foo\r")
    raw_cli.expect("test message")

    # unsubscribe, send ctrl-c
    raw_cli.send(chr(3))
    raw_cli.expect("0\r")