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

Function test_topk

tests/test_asyncio/test_bloom.py:273–350  ·  view source on GitHub ↗
(decoded_r: redis.Redis)

Source from the content-addressed store, hash-verified

271
272@pytest.mark.redismod
273async def test_topk(decoded_r: redis.Redis):
274 # test list with empty buckets
275 assert await decoded_r.topk().reserve("topk", 3, 50, 4, 0.9)
276 assert [
277 None,
278 None,
279 None,
280 "A",
281 "C",
282 "D",
283 None,
284 None,
285 "E",
286 None,
287 "B",
288 "C",
289 None,
290 None,
291 None,
292 "D",
293 None,
294 ] == await decoded_r.topk().add(
295 "topk",
296 "A",
297 "B",
298 "C",
299 "D",
300 "E",
301 "A",
302 "A",
303 "B",
304 "C",
305 "G",
306 "D",
307 "B",
308 "D",
309 "A",
310 "E",
311 "E",
312 1,
313 )
314 assert [1, 1, 0, 0, 1, 0, 0] == await decoded_r.topk().query(
315 "topk", "A", "B", "C", "D", "E", "F", "G"
316 )
317 with pytest.deprecated_call():
318 assert [4, 3, 2, 3, 3, 0, 1] == await decoded_r.topk().count(
319 "topk", "A", "B", "C", "D", "E", "F", "G"
320 )
321
322 # test full list
323 assert await decoded_r.topk().reserve("topklist", 3, 50, 3, 0.9)
324 assert await decoded_r.topk().add(
325 "topklist",
326 "A",
327 "B",
328 "C",
329 "D",
330 "E",

Callers

nothing calls this directly

Calls 7

reserveMethod · 0.80
listMethod · 0.80
topkMethod · 0.45
addMethod · 0.45
queryMethod · 0.45
countMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected