| 1 |
import pytest |
| 2 |
|
| 3 |
|
| 4 |
def test_zdiff(judge_command): |
| 5 |
"""ZDIFF (since 6.2) numkeys key [key ...] [WITHSCORES] (per commands.json).""" |
| 6 |
judge_command( |
| 7 |
"ZDIFF 2 zset1 zset2", |
| 8 |
{"command": "ZDIFF", "any": "2 zset1 zset2"}, |
| 9 |
) |
| 10 |
judge_command( |
| 11 |
"ZDIFF 3 k1 k2 k3 WITHSCORES", |
| 12 |
{"command": "ZDIFF", "any": "3 k1 k2 k3 WITHSCORES"}, |
| 13 |
) |
| 14 |
|
| 15 |
|
| 16 |
def test_zcount(judge_command): |
| 17 |
judge_command( |
| 18 |
"zcount foo -10 0", |
| 19 |
{"command": "zcount", "key": "foo", "min": "-10", "max": "0"}, |
| 20 |
) |
| 21 |
|
| 22 |
|
| 23 |
def test_bzpopmax(judge_command): |
| 24 |
judge_command( |
| 25 |
"bzpopmax set set2 set3 4", |
| 26 |
{"command": "bzpopmax", "keys": "set set2 set3", "timeout": "4"}, |
| 27 |
) |
| 28 |
judge_command( |
| 29 |
"bzpopmin set 4", {"command": "bzpopmin", "keys": "set", "timeout": "4"} |
| 30 |
) |
| 31 |
|
| 32 |
|
| 33 |
def test_zadd(judge_command): |
| 34 |
judge_command( |
| 35 |
"zadd t 100 qewqr 23 pp 11 oo", |
| 36 |
{ |
| 37 |
"command": "zadd", |
| 38 |
"key": "t", |
| 39 |
"score": "11", # FIXME: only have last one |
| 40 |
"member": "oo", |
| 41 |
}, |
| 42 |
) |
| 43 |
judge_command( |
| 44 |
"zadd t incr 100 foo", |
| 45 |
{ |
| 46 |
"command": "zadd", |
| 47 |
"key": "t", |
| 48 |
"incr": "incr", |
| 49 |
"score": "100", # FIXME: only have last one |
| 50 |
"member": "foo", |
| 51 |
}, |
| 52 |
) |
| 53 |
judge_command( |
| 54 |
"zadd t NX CH incr 100 foo", |
| 55 |
{ |
| 56 |
"command": "zadd", |
| 57 |
"key": "t", |
| 58 |
"condition": "NX", |
| 59 |
"changed": "CH", |
| 60 |
"incr": "incr", |
| 61 |
"score": "100", # FIXME: only have last one |
| 62 |
"member": "foo", |
| 63 |
}, |
| 64 |
) |
| 65 |
|
| 66 |
|
| 67 |
def test_zincrby(judge_command): |
| 68 |
judge_command( |
| 69 |
"zincrby t 10 foo", |
| 70 |
{"command": "zincrby", "key": "t", "float": "10", "member": "foo"}, |
| 71 |
) |
| 72 |
judge_command( |
| 73 |
"zincrby t 2.3 foo", |
| 74 |
{"command": "zincrby", "key": "t", "float": "2.3", "member": "foo"}, |
| 75 |
) |
| 76 |
|
| 77 |
|
| 78 |
def test_zlexcount(judge_command): |
| 79 |
judge_command( |
| 80 |
"zlexcount a - +", |
| 81 |
{"command": "zlexcount", "key": "a", "lexmin": "-", "lexmax": "+"}, |
| 82 |
) |
| 83 |
judge_command( |
| 84 |
"zlexcount a (aaaa [z", |
| 85 |
{"command": "zlexcount", "key": "a", "lexmin": "(aaaa", "lexmax": "[z"}, |
| 86 |
) |
| 87 |
judge_command( |
| 88 |
"ZLEXCOUNT myset - [c", |
| 89 |
{"command": "ZLEXCOUNT", "key": "myset", "lexmin": "-", "lexmax": "[c"}, |
| 90 |
) |
| 91 |
judge_command( |
| 92 |
"ZLEXCOUNT myset [aaa (g", |
| 93 |
{"command": "ZLEXCOUNT", "key": "myset", "lexmin": "[aaa", "lexmax": "(g"}, |
| 94 |
) |
| 95 |
|
| 96 |
|
| 97 |
def test_zrange(judge_command): |
| 98 |
judge_command( |
| 99 |
"zrange foo -1 10", |
| 100 |
{"command": "zrange", "key": "foo", "start": "-1", "end": "10"}, |
| 101 |
) |
| 102 |
judge_command( |
| 103 |
"zrange foo 0 -1", |
| 104 |
{"command": "zrange", "key": "foo", "start": "0", "end": "-1"}, |
| 105 |
) |
| 106 |
judge_command( |
| 107 |
"zrange foo 0 -1 withscores", |
| 108 |
{ |
| 109 |
"command": "zrange", |
| 110 |
"key": "foo", |
| 111 |
"start": "0", |
| 112 |
"end": "-1", |
| 113 |
"withscores": "withscores", |
| 114 |
}, |
| 115 |
) |
| 116 |
|
| 117 |
|
| 118 |
@pytest.mark.xfail(reason="Not implemented yet") |
| 119 |
def test_zinterstore(judge_command): |
| 120 |
judge_command("ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3", {}) |
| 121 |
judge_command("ZINTERSTORE out 2 zset1 zset2 WEIGHTS -1 -2", {}) |
| 122 |
judge_command("ZINTERSTORE out 2 zset1 zset2 WEIGHTS 0.2 0.3", {}) |
| 123 |
|
| 124 |
|
| 125 |
def test_zrangebylex(judge_command): |
| 126 |
judge_command( |
| 127 |
"ZRANGEBYLEX myzset [aaa (g", |
| 128 |
{"command": "ZRANGEBYLEX", "key": "myzset", "lexmin": "[aaa", "lexmax": "(g"}, |
| 129 |
) |
| 130 |
judge_command( |
| 131 |
"ZRANGEBYLEX myzset - (c", |
| 132 |
{"command": "ZRANGEBYLEX", "key": "myzset", "lexmin": "-", "lexmax": "(c"}, |
| 133 |
) |
| 134 |
judge_command( |
| 135 |
"ZRANGEBYLEX myzset - (c limit 10 100", |
| 136 |
{ |
| 137 |
"command": "ZRANGEBYLEX", |
| 138 |
"key": "myzset", |
| 139 |
"lexmin": "-", |
| 140 |
"lexmax": "(c", |
| 141 |
"limit": "limit", |
| 142 |
"offset": "10", |
| 143 |
"count": "100", |
| 144 |
}, |
| 145 |
) |
| 146 |
judge_command( |
| 147 |
"ZRANGEBYLEX myzset - (c limit 10 -1", |
| 148 |
{ |
| 149 |
"command": "ZRANGEBYLEX", |
| 150 |
"key": "myzset", |
| 151 |
"lexmin": "-", |
| 152 |
"lexmax": "(c", |
| 153 |
"limit": "limit", |
| 154 |
"offset": "10", |
| 155 |
"count": "-1", |
| 156 |
}, |
| 157 |
) |
| 158 |
|
| 159 |
|
| 160 |
def test_zrangebyscore(judge_command): |
| 161 |
judge_command( |
| 162 |
"ZRANGEBYSCORE myzset -inf +inf", |
| 163 |
{"command": "ZRANGEBYSCORE", "key": "myzset", "min": "-inf", "max": "+inf"}, |
| 164 |
) |
| 165 |
judge_command( |
| 166 |
"ZRANGEBYSCORE myzset 1 2", |
| 167 |
{"command": "ZRANGEBYSCORE", "key": "myzset", "min": "1", "max": "2"}, |
| 168 |
) |
| 169 |
judge_command( |
| 170 |
"ZRANGEBYSCORE myzset (1 (2", |
| 171 |
{"command": "ZRANGEBYSCORE", "key": "myzset", "min": "(1", "max": "(2"}, |
| 172 |
) |
| 173 |
judge_command( |
| 174 |
"ZRANGEBYSCORE myzset -inf +inf LIMIT 10 100", |
| 175 |
{ |
| 176 |
"command": "ZRANGEBYSCORE", |
| 177 |
"key": "myzset", |
| 178 |
"min": "-inf", |
| 179 |
"max": "+inf", |
| 180 |
"limit": "LIMIT", |
| 181 |
"offset": "10", |
| 182 |
"count": "100", |
| 183 |
}, |
| 184 |
) |