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

Method test_xadd_minlen_and_limit

tests/test_commands.py:6353–6396  ·  view source on GitHub ↗
(self, r)

Source from the content-addressed store, hash-verified

6351
6352 @skip_if_server_version_lt("6.2.0")
6353 def test_xadd_minlen_and_limit(self, r):
6354 stream = "stream"
6355
6356 r.xadd(stream, {"foo": "bar"})
6357 r.xadd(stream, {"foo": "bar"})
6358 r.xadd(stream, {"foo": "bar"})
6359 r.xadd(stream, {"foo": "bar"})
6360
6361 # Future self: No limits without approximate, according to the api
6362 with pytest.raises(redis.ResponseError):
6363 assert r.xadd(stream, {"foo": "bar"}, maxlen=3, approximate=False, limit=2)
6364
6365 # limit can not be provided without maxlen or minid
6366 with pytest.raises(redis.ResponseError):
6367 assert r.xadd(stream, {"foo": "bar"}, limit=2)
6368
6369 # maxlen with a limit
6370 assert r.xadd(stream, {"foo": "bar"}, maxlen=3, approximate=True, limit=2)
6371 r.delete(stream)
6372
6373 # maxlen and minid can not be provided together
6374 with pytest.raises(redis.DataError):
6375 assert r.xadd(stream, {"foo": "bar"}, maxlen=3, minid="sometestvalue")
6376
6377 # minid with a limit
6378 m1 = r.xadd(stream, {"foo": "bar"})
6379 r.xadd(stream, {"foo": "bar"})
6380 r.xadd(stream, {"foo": "bar"})
6381 r.xadd(stream, {"foo": "bar"})
6382 assert r.xadd(stream, {"foo": "bar"}, approximate=True, minid=m1, limit=3)
6383
6384 # pure minid
6385 r.xadd(stream, {"foo": "bar"})
6386 r.xadd(stream, {"foo": "bar"})
6387 r.xadd(stream, {"foo": "bar"})
6388 m4 = r.xadd(stream, {"foo": "bar"})
6389 assert r.xadd(stream, {"foo": "bar"}, approximate=False, minid=m4)
6390
6391 # minid approximate
6392 r.xadd(stream, {"foo": "bar"})
6393 r.xadd(stream, {"foo": "bar"})
6394 m3 = r.xadd(stream, {"foo": "bar"})
6395 r.xadd(stream, {"foo": "bar"})
6396 assert r.xadd(stream, {"foo": "bar"}, approximate=True, minid=m3)
6397
6398 @skip_if_server_version_lt("7.0.0")
6399 def test_xadd_explicit_ms(self, r: redis.Redis):

Callers

nothing calls this directly

Calls 2

xaddMethod · 0.80
deleteMethod · 0.45

Tested by

no test coverage detected