MCPcopy
hub / github.com/redis/redis-py / test_zadd

Method test_zadd

tests/test_asyncio/test_commands.py:3436–3457  ·  view source on GitHub ↗
(self, r: redis.Redis)

Source from the content-addressed store, hash-verified

3434
3435 # SORTED SET COMMANDS
3436 async def test_zadd(self, r: redis.Redis):
3437 mapping = {"a1": 1.0, "a2": 2.0, "a3": 3.0}
3438 await r.zadd("a", mapping)
3439 response = await r.zrange("a", 0, -1, withscores=True)
3440 assert_resp_response(
3441 r,
3442 response,
3443 [(b"a1", 1.0), (b"a2", 2.0), (b"a3", 3.0)],
3444 [[b"a1", 1.0], [b"a2", 2.0], [b"a3", 3.0]],
3445 )
3446
3447 # error cases
3448 with pytest.raises(exceptions.DataError):
3449 await r.zadd("a", {})
3450
3451 # cannot use both nx and xx options
3452 with pytest.raises(exceptions.DataError):
3453 await r.zadd("a", mapping, nx=True, xx=True)
3454
3455 # cannot use the incr options with more than one value
3456 with pytest.raises(exceptions.DataError):
3457 await r.zadd("a", mapping, incr=True)
3458
3459 async def test_zadd_nx(self, r: redis.Redis):
3460 assert await r.zadd("a", {"a1": 1}) == 1

Callers

nothing calls this directly

Calls 3

assert_resp_responseFunction · 0.90
zaddMethod · 0.80
zrangeMethod · 0.80

Tested by

no test coverage detected