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

Function test_topk

tests/test_bloom.py:305–381  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

303
304@pytest.mark.redismod
305def test_topk(client):
306 # test list with empty buckets
307 assert client.topk().reserve("topk", 3, 50, 4, 0.9)
308 assert [
309 None,
310 None,
311 None,
312 "A",
313 "C",
314 "D",
315 None,
316 None,
317 "E",
318 None,
319 "B",
320 "C",
321 None,
322 None,
323 None,
324 "D",
325 None,
326 ] == client.topk().add(
327 "topk",
328 "A",
329 "B",
330 "C",
331 "D",
332 "E",
333 "A",
334 "A",
335 "B",
336 "C",
337 "G",
338 "D",
339 "B",
340 "D",
341 "A",
342 "E",
343 "E",
344 1,
345 )
346 assert [1, 1, 0, 0, 1, 0, 0] == client.topk().query(
347 "topk", "A", "B", "C", "D", "E", "F", "G"
348 )
349 with pytest.deprecated_call():
350 assert [4, 3, 2, 3, 3, 0, 1] == client.topk().count(
351 "topk", "A", "B", "C", "D", "E", "F", "G"
352 )
353
354 # test full list
355 assert client.topk().reserve("topklist", 3, 50, 3, 0.9)
356 assert client.topk().add(
357 "topklist",
358 "A",
359 "B",
360 "C",
361 "D",
362 "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