11# pylint: disable=redefined-outer-name
2+ import os
23import json
34from typing import Optional
45
@@ -16,19 +17,31 @@ def client():
1617 return meilisearch .Client (common .BASE_URL , common .MASTER_KEY )
1718
1819
20+ @fixture (scope = "session" )
21+ def client2 ():
22+ return meilisearch .Client (common .BASE_URL_2 , common .MASTER_KEY )
23+
24+
25+ def _clear_indexes (meilisearch_client ):
26+ """Deletes all the indexes in the Meilisearch instance."""
27+
28+ indexes = meilisearch_client .get_indexes ()
29+ for index in indexes ["results" ]:
30+ task = meilisearch_client .index (index .uid ).delete ()
31+ meilisearch_client .wait_for_task (task .task_uid )
32+
33+
1934@fixture (autouse = True )
20- def clear_indexes (client ):
35+ def clear_indexes (client , client2 ):
2136 """
2237 Auto-clears the indexes after each test function run.
2338 Makes all the test functions independent.
2439 """
2540 # Yields back to the test function.
2641 yield
27- # Deletes all the indexes in the Meilisearch instance.
28- indexes = client .get_indexes ()
29- for index in indexes ["results" ]:
30- task = client .index (index .uid ).delete ()
31- client .wait_for_task (task .task_uid )
42+ _clear_indexes (client )
43+ if os .getenv ("MEILISEARCH_URL_2" ):
44+ _clear_indexes (client2 )
3245
3346
3447@fixture (autouse = True )
@@ -47,12 +60,14 @@ def clear_webhooks(client):
4760
4861
4962@fixture (autouse = True )
50- def clear_all_tasks (client ):
63+ def clear_all_tasks (client , client2 ):
5164 """
5265 Auto-clears the tasks after each test function run.
5366 Makes all the test functions independent.
5467 """
5568 client .delete_tasks ({"statuses" : ["succeeded" , "failed" , "canceled" ]})
69+ if os .getenv ("MEILISEARCH_URL_2" ):
70+ client2 .delete_tasks ({"statuses" : ["succeeded" , "failed" , "canceled" ]})
5671
5772
5873@fixture (scope = "function" )
0 commit comments