Skip to content

Commit b9af137

Browse files
committed
Improve tests
1 parent e0baeeb commit b9af137

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

meilisearch/models/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Task(CamelBase):
1111
status: str
1212
type: str
1313
details: Dict[str, Any]
14-
error: Dict[str, Any]
14+
error: Union[Dict[str, Any], None]
1515
canceled_by: Union[int, None]
1616
duration: str
1717
enqueued_at: str

tests/client/test_client_task_meilisearch.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,20 @@ def test_get_task_inexistent(client):
9696

9797
def test_cancel_tasks(client):
9898
"""Tests cancel a task with uid 1."""
99-
task = client.cancel_tasks({"uids": ["1"]})
99+
task = client.cancel_tasks({"uids": ["1", "2"]})
100100
tasks = client.get_tasks({"types": "taskCancelation"})
101101

102102
assert isinstance(task, TaskInfo)
103103
assert task.task_uid is not None
104104
assert task.index_uid is None
105-
assert task.status == "enqueued" or "processing" or "succeeded"
105+
assert task.status in {"enqueued", "processing", "succeeded"}
106106
assert task.type == "taskCancelation"
107107
assert "uids" in tasks["results"][0]["details"]["originalFilters"]
108+
assert any(
109+
substring in tasks["results"][0]["details"]["originalFilters"]
110+
for substring in ["uids", "1", "2"]
111+
)
112+
108113

109114
def test_cancel_every_task(client):
110115
"""Tests cancel every task."""
@@ -114,8 +119,9 @@ def test_cancel_every_task(client):
114119
assert isinstance(task, TaskInfo)
115120
assert task.task_uid is not None
116121
assert task.index_uid is None
117-
assert task.status == "enqueued" or "processing" or "succeeded"
122+
assert task.status in {"enqueued", "processing", "succeeded"}
118123
assert task.type == "taskCancelation"
119-
assert "statuses" in tasks["results"][0]["details"]["originalFilters"]
120-
121-
124+
assert any(
125+
substring in tasks["results"][0]["details"]["originalFilters"]
126+
for substring in ["statuses", "enqueued", "processing"]
127+
)

0 commit comments

Comments
 (0)