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

Method test_client

tests/test_asyncio/test_search.py:143–378  ·  view source on GitHub ↗
(self, decoded_r: redis.Redis)

Source from the content-addressed store, hash-verified

141class TestBaseSearchFunctionality(AsyncSearchTestsBase):
142 @pytest.mark.redismod
143 async def test_client(self, decoded_r: redis.Redis):
144 num_docs = 500
145 await self.createIndex(decoded_r.ft(), num_docs=num_docs)
146 await self.waitForIndex(decoded_r, "idx")
147 # verify info
148 info = await decoded_r.ft().info()
149 for k in [
150 "index_name",
151 "index_options",
152 "attributes",
153 "num_docs",
154 "max_doc_id",
155 "num_terms",
156 "num_records",
157 "inverted_sz_mb",
158 "offset_vectors_sz_mb",
159 "doc_table_size_mb",
160 "key_table_size_mb",
161 "records_per_doc_avg",
162 "bytes_per_record_avg",
163 "offsets_per_term_avg",
164 "offset_bits_per_record_avg",
165 ]:
166 assert k in info
167
168 assert decoded_r.ft().index_name == info["index_name"]
169 assert num_docs == int(info["num_docs"])
170
171 res = await decoded_r.ft().search("henry iv")
172 if expects_resp2_shape(decoded_r) or expects_unified_shape(decoded_r):
173 assert isinstance(res, Result)
174 assert 225 == res.total
175 assert 10 == len(res.docs)
176 assert res.duration > 0
177
178 for doc in res.docs:
179 assert doc.id
180 assert doc.play == "Henry IV"
181 assert len(doc.txt) > 0
182
183 # test no content
184 res = await decoded_r.ft().search(Query("king").no_content())
185 assert 194 == res.total
186 assert 10 == len(res.docs)
187 for doc in res.docs:
188 assert "txt" not in doc.__dict__
189 assert "play" not in doc.__dict__
190
191 # test verbatim vs no verbatim
192 total = (await decoded_r.ft().search(Query("kings").no_content())).total
193 vtotal = (
194 await decoded_r.ft().search(Query("kings").no_content().verbatim())
195 ).total
196 assert total > vtotal
197
198 # test in fields
199 txt_total = (
200 await decoded_r.ft().search(

Callers

nothing calls this directly

Calls 15

expects_resp2_shapeFunction · 0.90
expects_unified_shapeFunction · 0.90
QueryClass · 0.90
expects_resp3_shapeFunction · 0.90
no_contentMethod · 0.80
limit_fieldsMethod · 0.80
limit_idsMethod · 0.80
in_orderMethod · 0.80
slopMethod · 0.80
hsetMethod · 0.80
delete_documentMethod · 0.80
keysMethod · 0.80

Tested by

no test coverage detected