Skip to content

Commit 7e2fd46

Browse files
committed
fix
1 parent 68831d5 commit 7e2fd46

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

meilisearch/client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
MeilisearchError,
3131
)
3232
from meilisearch.index import Index
33+
from meilisearch.models.dynamic_search_rule import DynamicSearchRule, DynamicSearchRuleResults
3334
from meilisearch.models.key import Key, KeysResults
3435
from meilisearch.models.task import Batch, BatchResults, Task, TaskInfo, TaskResults
3536
from meilisearch.models.webhook import Webhook, WebhooksResults
36-
from meilisearch.models.dynamic_search_rule import DynamicSearchRule, DynamicSearchRuleResults
3737
from meilisearch.task import TaskHandler
3838

3939

@@ -601,9 +601,9 @@ def delete_webhook(self, webhook_uuid: str) -> int:
601601
"""
602602
response = self.http.delete(f"{self.config.paths.webhooks}/{webhook_uuid}")
603603
return response.status_code
604-
604+
605605
# DYNAMIC SEARCH RULES ROUTES
606-
606+
607607
def get_dynamic_search_rules(self) -> DynamicSearchRuleResults:
608608
"""Get all dynamic search rules.
609609
@@ -675,7 +675,6 @@ def create_or_update_dynamic_search_rule(
675675
rule = self.http.patch(f"{self.config.paths.dynamic_search_rules}/{uid}", options)
676676
return DynamicSearchRule(**rule)
677677

678-
679678
def delete_dynamic_search_rule(self, uid: str) -> int:
680679
"""Delete a dynamic search rule.
681680
@@ -700,7 +699,6 @@ def delete_dynamic_search_rule(self, uid: str) -> int:
700699
response = self.http.delete(f"{self.config.paths.dynamic_search_rules}/{uid}")
701700
return response.status_code
702701

703-
704702
def get_version(self) -> Dict[str, str]:
705703
"""Get version Meilisearch
706704

meilisearch/models/dynamic_search_rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ class DynamicSearchRuleResults(CamelBase):
2424
results: List[DynamicSearchRule]
2525
offset: int
2626
limit: int
27-
total: int
27+
total: int

tests/client/test_client_dynamic_search_rules_meilisearch.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from meilisearch.errors import MeilisearchApiError
66

7+
pytestmark = pytest.mark.usefixtures("enable_dynamic_search_rules")
8+
79

810
def test_get_dynamic_search_rules_empty(client):
911
"""Test getting dynamic search rules when none exist."""
@@ -19,13 +21,11 @@ def test_create_or_update_dynamic_search_rule(client):
1921
"description": "Test rule for promotion",
2022
"priority": 10,
2123
"active": True,
22-
"conditions": [
23-
{"scope": "query", "isEmpty": True}
24-
],
24+
"conditions": [{"scope": "query", "isEmpty": True}],
2525
"actions": [
2626
{
2727
"selector": {"indexUid": "movies", "id": "123"},
28-
"action": {"type": "pin", "position": 1}
28+
"action": {"type": "pin", "position": 1},
2929
}
3030
],
3131
}
@@ -68,13 +68,11 @@ def test_update_dynamic_search_rule(client):
6868
"description": "Original description",
6969
"priority": 10,
7070
"active": True,
71-
"conditions": [
72-
{"scope": "query", "isEmpty": True}
73-
],
71+
"conditions": [{"scope": "query", "isEmpty": True}],
7472
"actions": [
7573
{
7674
"selector": {"indexUid": "movies", "id": "123"},
77-
"action": {"type": "pin", "position": 1}
75+
"action": {"type": "pin", "position": 1},
7876
}
7977
],
8078
}

tests/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,20 @@ def enable_network_options():
352352
json={"network": False},
353353
timeout=10,
354354
)
355+
356+
357+
@fixture
358+
def enable_dynamic_search_rules():
359+
requests.patch(
360+
f"{common.BASE_URL}/experimental-features",
361+
headers={"Authorization": f"Bearer {common.MASTER_KEY}"},
362+
json={"dynamicSearchRules": True},
363+
timeout=10,
364+
)
365+
yield
366+
requests.patch(
367+
f"{common.BASE_URL}/experimental-features",
368+
headers={"Authorization": f"Bearer {common.MASTER_KEY}"},
369+
json={"dynamicSearchRules": False},
370+
timeout=10,
371+
)

0 commit comments

Comments
 (0)