Skip to content

Commit c0093d0

Browse files
committed
better test
1 parent c5ed6bc commit c0093d0

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

tests/openapi/test_strictmode.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,24 +239,29 @@ def search_request_with_filter():
239239
}
240240
)
241241

242+
# works without strict mode
242243
search_request_with_filter().raise_for_status()
243244

245+
# enable strict mode `unindexed_filtering_retrieve`
244246
set_strict_mode(collection_name, {
245247
"enabled": True,
246248
"unindexed_filtering_retrieve": True,
247249
})
248250

251+
# still works
249252
search_request_with_filter().raise_for_status()
250253

254+
# toggle `unindexed_filtering_retrieve`
251255
set_strict_mode(collection_name, {
252256
"unindexed_filtering_retrieve": False,
253257
})
254258

259+
# search fail because no payload index
255260
search_fail = search_request_with_filter()
256-
257261
assert "count" in search_fail.json()['status']['error']
258262
assert not search_fail.ok
259263

264+
# create payload index
260265
request_with_validation(
261266
api='/collections/{collection_name}/index',
262267
method="PUT",
@@ -266,16 +271,16 @@ def search_request_with_filter():
266271
"field_name": "count",
267272
"field_schema": {
268273
"type": "integer",
269-
"lookup": False,
274+
"lookup": True,
270275
"range": True,
271276
}
272277
}
273278
).raise_for_status()
274279

275-
# the integer index does not support `lookup` on our match condition
276-
assert "count" in search_fail.json()['status']['error']
277-
assert not search_fail.ok
280+
# works now by leveraging index
281+
search_request_with_filter().raise_for_status()
278282

283+
# remove lookup capacity on index
279284
request_with_validation(
280285
api='/collections/{collection_name}/index',
281286
method="PUT",
@@ -285,14 +290,16 @@ def search_request_with_filter():
285290
"field_name": "count",
286291
"field_schema": {
287292
"type": "integer",
288-
"lookup": True,
293+
"lookup": False,
289294
"range": True,
290295
}
291296
}
292297
).raise_for_status()
293-
294-
# We created an index with `lookup` on this field so it should work now
295-
search_request_with_filter().raise_for_status()
298+
299+
# fails because the integer index does not support `lookup` for our match condition
300+
search_fail = search_request_with_filter()
301+
assert "count" in search_fail.json()['status']['error']
302+
assert not search_fail.ok
296303

297304

298305
def test_strict_mode_unindexed_filter_write_validation(collection_name):

0 commit comments

Comments
 (0)