Skip to content

Commit c5bd2be

Browse files
author
diana
committed
fix: Use correct v1.41 conditions array structure in test payloads
Replace single 'condition' string with 'conditions' array containing scope/operator/value objects. Move matchCondition inside actions object. All payloads now match the v1.41 Dynamic Search Rules API spec.
1 parent 6f918cb commit c5bd2be

1 file changed

Lines changed: 33 additions & 21 deletions

File tree

tests/index/test_index_dynamic_search_rules_meilisearch.py

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,28 @@ def test_list_dynamic_search_rules(test_index):
2020

2121
def test_get_dynamic_search_rule(test_index):
2222
"""Test getting a single dynamic search rule"""
23-
# Create a rule first
2423
rule_uid = "test-rule-1"
2524
rule_body = {
26-
"condition": "query = 'new'",
27-
"matchCondition": "all",
25+
"conditions": [
26+
{
27+
"scope": ["title"],
28+
"operator": "contains",
29+
"value": "new"
30+
}
31+
],
2832
"actions": [
2933
{
3034
"action": "promote",
3135
"documentIds": ["1"],
36+
"matchCondition": "all",
3237
"position": 1
3338
}
3439
]
3540
}
36-
41+
3742
create_response = test_index.upsert_dynamic_search_rule(rule_uid, rule_body)
3843
test_index.wait_for_task(create_response.task_uid)
39-
40-
# Now retrieve it
44+
4145
response = test_index.get_dynamic_search_rule(rule_uid)
4246
assert isinstance(response, dict)
4347
assert response.get("uid") == rule_uid
@@ -47,23 +51,28 @@ def test_upsert_dynamic_search_rule(test_index):
4751
"""Test creating or updating a dynamic search rule"""
4852
rule_uid = "test-rule-2"
4953
rule_body = {
50-
"condition": "query = 'hello'",
51-
"matchCondition": "all",
54+
"conditions": [
55+
{
56+
"scope": ["title"],
57+
"operator": "contains",
58+
"value": "hello"
59+
}
60+
],
5261
"actions": [
5362
{
5463
"action": "promote",
5564
"documentIds": ["2"],
65+
"matchCondition": "all",
5666
"position": 1
5767
}
5868
]
5969
}
60-
70+
6171
response = test_index.upsert_dynamic_search_rule(rule_uid, rule_body)
6272
assert response.task_uid is not None
63-
73+
6474
test_index.wait_for_task(response.task_uid)
65-
66-
# Verify it was created
75+
6776
retrieved = test_index.get_dynamic_search_rule(rule_uid)
6877
assert retrieved.get("uid") == rule_uid
6978

@@ -72,27 +81,30 @@ def test_delete_dynamic_search_rule(test_index):
7281
"""Test deleting a dynamic search rule"""
7382
rule_uid = "test-rule-3"
7483
rule_body = {
75-
"condition": "query = 'delete-me'",
76-
"matchCondition": "all",
84+
"conditions": [
85+
{
86+
"scope": ["title"],
87+
"operator": "contains",
88+
"value": "delete-me"
89+
}
90+
],
7791
"actions": [
7892
{
7993
"action": "promote",
8094
"documentIds": ["3"],
95+
"matchCondition": "all",
8196
"position": 1
8297
}
8398
]
8499
}
85-
86-
# Create rule
100+
87101
create_response = test_index.upsert_dynamic_search_rule(rule_uid, rule_body)
88102
test_index.wait_for_task(create_response.task_uid)
89-
90-
# Delete it
103+
91104
delete_response = test_index.delete_dynamic_search_rule(rule_uid)
92105
assert delete_response.task_uid is not None
93-
106+
94107
test_index.wait_for_task(delete_response.task_uid)
95-
96-
# Verify it's deleted - should raise error or return empty
108+
97109
with pytest.raises(MeilisearchApiError):
98110
test_index.get_dynamic_search_rule(rule_uid)

0 commit comments

Comments
 (0)