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

Method test_profile

tests/test_search.py:2642–2683  ·  view source on GitHub ↗
(self, client)

Source from the content-addressed store, hash-verified

2640 @skip_if_server_version_gte("7.9.0")
2641 @skip_if_server_version_lt("6.3.0")
2642 def test_profile(self, client):
2643 client.ft().create_index((TextField("t"),))
2644 client.ft().client.hset("1", "t", "hello")
2645 client.ft().client.hset("2", "t", "world")
2646
2647 # check using Query
2648 q = Query("hello|world").no_content()
2649 if expects_resp2_shape(client) or expects_unified_shape(client):
2650 res, det = client.ft().profile(q)
2651 det = det.info
2652
2653 assert isinstance(det, list)
2654 assert len(res.docs) == 2 # check also the search result
2655
2656 # check using AggregateRequest
2657 req = (
2658 aggregations.AggregateRequest("*")
2659 .load("t")
2660 .apply(prefix="startswith(@t, 'hel')")
2661 )
2662 res, det = client.ft().profile(req)
2663 det = det.info
2664 assert isinstance(det, list)
2665 assert len(res.rows) == 2 # check also the search result
2666 elif expects_resp3_shape(client):
2667 res = client.ft().profile(q)
2668 res = res.info
2669
2670 assert isinstance(res, dict)
2671 assert len(res["results"]) == 2 # check also the search result
2672
2673 # check using AggregateRequest
2674 req = (
2675 aggregations.AggregateRequest("*")
2676 .load("t")
2677 .apply(prefix="startswith(@t, 'hel')")
2678 )
2679 res = client.ft().profile(req)
2680 res = res.info
2681
2682 assert isinstance(res, dict)
2683 assert len(res["results"]) == 2 # check also the search result
2684
2685 @pytest.mark.redismod
2686 @pytest.mark.onlynoncluster

Callers

nothing calls this directly

Calls 12

TextFieldClass · 0.90
QueryClass · 0.90
expects_resp2_shapeFunction · 0.85
expects_unified_shapeFunction · 0.85
expects_resp3_shapeFunction · 0.85
create_indexMethod · 0.80
hsetMethod · 0.80
no_contentMethod · 0.80
profileMethod · 0.80
ftMethod · 0.45
applyMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected