@@ -9,6 +9,7 @@ class TestIndex:
9
9
client = meilisearch .Client (BASE_URL , MASTER_KEY )
10
10
index_uid = 'indexUID'
11
11
index_uid2 = 'indexUID2'
12
+ index_uid3 = 'indexUID3'
12
13
13
14
def setup_class (self ):
14
15
clear_all_indexes (self .client )
@@ -27,11 +28,22 @@ def test_create_index_with_primary_key(self):
27
28
assert index .uid == self .index_uid2
28
29
assert index .get_primary_key () == 'book_id'
29
30
31
+ def test_create_index_with_uid_in_options (self ):
32
+ """Tests creating an index with a primary key"""
33
+ index = self .client .create_index (uid = self .index_uid3 , options = {'uid' : 'wrong' , 'primaryKey' : 'book_id' })
34
+ assert isinstance (index , object )
35
+ assert index .uid == self .index_uid3
36
+ assert index .get_primary_key () == 'book_id'
37
+
30
38
def test_get_indexes (self ):
31
39
"""Tests getting all indexes"""
32
40
response = self .client .get_indexes ()
41
+ uids = [index ['uid' ] for index in response ]
33
42
assert isinstance (response , list )
34
- assert response [0 ]['uid' ] == self .index_uid
43
+ assert self .index_uid in uids
44
+ assert self .index_uid2 in uids
45
+ assert self .index_uid3 in uids
46
+ assert len (response ) == 3
35
47
36
48
def test_get_index_with_uid (self ):
37
49
"""Tests getting one index with uid"""
@@ -84,3 +96,10 @@ def test_delete_index(self):
84
96
assert response .status_code == 204
85
97
with pytest .raises (Exception ):
86
98
self .client .get_index (uid = self .index_uid2 ).info ()
99
+ index = self .client .get_index (uid = self .index_uid3 )
100
+ response = index .delete ()
101
+ assert isinstance (response , object )
102
+ assert response .status_code == 204
103
+ with pytest .raises (Exception ):
104
+ self .client .get_index (uid = self .index_uid3 ).info ()
105
+ assert len (self .client .get_indexes ()) == 0
0 commit comments