File tree Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Expand file tree Collapse file tree 3 files changed +24
-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 4
4
5
5
import requests
6
6
from pytest import fixture
7
+ from urllib3 import request
7
8
8
9
import meilisearch
9
10
from meilisearch .errors import MeilisearchApiError
@@ -230,6 +231,23 @@ def enable_vector_search():
230
231
)
231
232
232
233
234
+ @fixture
235
+ def enable_edit_documents_by_function ():
236
+ requests .patch (
237
+ f"{ common .BASE_URL } /experimental-features" ,
238
+ headers = {"Authorization" : f"Bearer { common .MASTER_KEY } " },
239
+ json = {"editDocumentsByFunction" : True },
240
+ timeout = 10 ,
241
+ )
242
+ yield
243
+ requests .patch (
244
+ f"{ common .BASE_URL } /experimental-features" ,
245
+ headers = {"Authorization" : f"Bearer { common .MASTER_KEY } " },
246
+ json = {"editDocumentsByFunction" : False },
247
+ timeout = 10 ,
248
+ )
249
+
250
+
233
251
@fixture
234
252
def new_embedders ():
235
253
return {
You can’t perform that action at this time.
0 commit comments