File tree Expand file tree Collapse file tree 3 files changed +23
-8
lines changed Expand file tree Collapse file tree 3 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -65,9 +65,7 @@ def send_request(
65
65
data = (
66
66
json .dumps (body , cls = serializer )
67
67
if serialize_body
68
- else ""
69
- if body == ""
70
- else "null"
68
+ else "" if body == "" else "null"
71
69
)
72
70
73
71
request = http_method (
Original file line number Diff line number Diff line change 1
1
import pytest
2
2
3
- from meilisearch .errors import MeilisearchApiError
4
3
from tests .common import INDEX_UID
5
- from tests .conftest import index_with_documents
6
4
7
5
8
- def test_basic_multi_search (client , index_with_documents ):
9
- """Delete the document with id."""
6
+ @pytest .mark .usefixtures ("enable_edit_documents_by_function" )
7
+ def test_update_document_by_function (client , index_with_documents ):
8
+ """Delete the document with id and update document title"""
10
9
index_with_documents ()
11
10
response = client .update_documents_by_function (
12
- "indexA" ,
11
+ INDEX_UID ,
13
12
{"function" : 'if doc.id == "522681" {doc = () } else {doc.title = `* ${doc.title} *`}' },
14
13
)
15
14
16
15
assert isinstance (response , dict )
16
+ assert isinstance (response ["taskUid" ], int )
17
17
assert response ["indexUid" ] == INDEX_UID
Original file line number Diff line number Diff line change @@ -230,6 +230,23 @@ def enable_vector_search():
230
230
)
231
231
232
232
233
+ @fixture
234
+ def enable_edit_documents_by_function ():
235
+ requests .patch (
236
+ f"{ common .BASE_URL } /experimental-features" ,
237
+ headers = {"Authorization" : f"Bearer { common .MASTER_KEY } " },
238
+ json = {"editDocumentsByFunction" : True },
239
+ timeout = 10 ,
240
+ )
241
+ yield
242
+ requests .patch (
243
+ f"{ common .BASE_URL } /experimental-features" ,
244
+ headers = {"Authorization" : f"Bearer { common .MASTER_KEY } " },
245
+ json = {"editDocumentsByFunction" : False },
246
+ timeout = 10 ,
247
+ )
248
+
249
+
233
250
@fixture
234
251
def new_embedders ():
235
252
return {
You can’t perform that action at this time.
0 commit comments