Skip to content

Commit 5cbd39a

Browse files
committed
Modification due to review
1 parent 34f81f7 commit 5cbd39a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

meilisearch/client.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def is_healthy(self) -> bool:
217217
return False
218218
return True
219219

220-
def get_key(self, key: str) -> Dict[str, str]:
220+
def get_key(self, key: str) -> Dict[str, Any]:
221221
"""Gets information about a specific API key.
222222
223223
Parameters
@@ -238,7 +238,7 @@ def get_key(self, key: str) -> Dict[str, str]:
238238
"""
239239
return self.http.get(f'{self.config.paths.keys}/{key}')
240240

241-
def get_keys(self) -> Dict[str, str]:
241+
def get_keys(self) -> List[Dict[str, Any]]:
242242
"""Gets the MeiliSearch API keys.
243243
244244
Returns
@@ -256,7 +256,7 @@ def get_keys(self) -> Dict[str, str]:
256256

257257
def create_key(
258258
self,
259-
options: Optional[Dict[str, Any]] = None
259+
options: Dict[str, Any]
260260
) -> Dict[str, int]:
261261
"""Creates a new API key.
262262
@@ -288,17 +288,18 @@ def create_key(
288288
def udpate_key(
289289
self,
290290
key: str,
291-
options: Optional[Dict[str, Any]] = None
291+
options: Dict[str, Any]
292292
) -> Dict[str, int]:
293293
"""Update an API key.
294294
295295
Parameters
296+
296297
----------
297298
key:
298-
The information to use in updating the key. Note that if an expires_at value
299-
is included it should be in UTC time.
299+
The key for which to update the information.
300300
options:
301-
Options, the information to use in creating the key (ex: { 'description': 'Search Key', 'expiresAt': '22-01-01' }).
301+
The information to use in creating the key (ex: { 'description': 'Search Key', 'expiresAt': '22-01-01' }). Note that if an
302+
expires_at value is included it should be in UTC time.
302303
303304
Returns
304305
-------

tests/client/test_client_key_meilisearch.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import pytest
22
from tests import common
3-
from datetime import datetime, timedelta
3+
from datetime import datetime
44

55
def test_get_keys_default(client):
66
"""Tests if public and private keys have been generated and can be retrieved."""
77
key = client.get_keys()
88
assert isinstance(key, list)
9-
assert len(key) >= 2
9+
assert len(key) == 2
1010
assert 'actions' in key[0]
1111
assert 'indexes' in key[0]
1212
assert key[0]['key'] is not None
@@ -40,6 +40,7 @@ def test_create_keys_default(client):
4040
assert key['key'] is not None
4141
assert key['actions'] == ['*']
4242
assert key['indexes'] == [common.INDEX_UID]
43+
client.delete_key(key['key'])
4344

4445
def test_create_keys_with_options(client):
4546
"""Tests the creation of a key with arguments."""
@@ -52,6 +53,7 @@ def test_create_keys_with_options(client):
5253
assert key['updatedAt'] is not None
5354
assert key['actions'] == ['*']
5455
assert key['indexes'] == [common.INDEX_UID]
56+
client.delete_key(key['key'])
5557

5658
def test_create_keys_without_actions(client):
5759
"""Tests the creation of a key with missing arguments."""
@@ -66,6 +68,7 @@ def test_update_keys(client):
6668
assert update_key['key'] is not None
6769
assert update_key['expiresAt'] is None
6870
assert update_key['actions'] == ['search']
71+
client.delete_key(update_key['key'])
6972

7073
def test_delete_key(client):
7174
"""Tests deleting a key."""

0 commit comments

Comments
 (0)