File tree Expand file tree Collapse file tree 2 files changed +39
-11
lines changed Expand file tree Collapse file tree 2 files changed +39
-11
lines changed Original file line number Diff line number Diff line change 1
1
# pylint: disable=invalid-name
2
2
3
- import pytest
4
-
5
3
import meilisearch
6
- from meilisearch .errors import MeiliSearchTimeoutError
7
4
from meilisearch .tests import BASE_URL , MASTER_KEY
8
5
6
+
9
7
def test_get_client ():
10
8
"""Tests getting a client instance."""
11
9
client = meilisearch .Client (BASE_URL , MASTER_KEY )
@@ -15,19 +13,16 @@ def test_get_client():
15
13
16
14
17
15
def test_client_timeout_set ():
18
- client = meilisearch .Client (BASE_URL , MASTER_KEY , timeout = 5 )
16
+ timeout = 5
17
+ client = meilisearch .Client (BASE_URL , MASTER_KEY , timeout = timeout )
19
18
response = client .health ()
19
+ assert client .config .timeout == timeout
20
20
assert response .status_code >= 200 and response .status_code < 400
21
21
22
22
23
23
def test_client_timeout_not_set ():
24
+ default_timeout = 10
24
25
client = meilisearch .Client (BASE_URL , MASTER_KEY )
25
26
response = client .health ()
27
+ assert client .config .timeout == default_timeout
26
28
assert response .status_code >= 200 and response .status_code < 400
27
-
28
-
29
- def test_client_timeout_error ():
30
- client = meilisearch .Client ("http://wrongurl:1234" , MASTER_KEY , timeout = 1 )
31
-
32
- with pytest .raises (MeiliSearchTimeoutError ):
33
- client .health ()
Original file line number Diff line number Diff line change
1
+ import pytest
2
+ import meilisearch
3
+ from meilisearch .errors import MeiliSearchTimeoutError
4
+ from meilisearch .tests import BASE_URL , MASTER_KEY
5
+
6
+
7
+ @pytest .mark .usefixtures ("indexes_sample" )
8
+ def test_client_timeout_error (small_movies ):
9
+ client = meilisearch .Client (BASE_URL , MASTER_KEY , timeout = 1e-99 )
10
+
11
+ with pytest .raises (MeiliSearchTimeoutError ):
12
+ index = client .index ("indexUID" )
13
+ index .add_documents (small_movies )
14
+
15
+
16
+ def test_client_timeout_set ():
17
+ timeout = 1
18
+ client = meilisearch .Client ("http://wrongurl:1234" , MASTER_KEY , timeout = timeout )
19
+
20
+ with pytest .raises (Exception ):
21
+ client .health ()
22
+
23
+ assert client .config .timeout == timeout
24
+
25
+
26
+ def test_client_timeout_not_set ():
27
+ timeout = 10
28
+ client = meilisearch .Client ("http://wrongurl:1234" , MASTER_KEY )
29
+
30
+ with pytest .raises (Exception ):
31
+ client .health ()
32
+
33
+ assert client .config .timeout == timeout
You can’t perform that action at this time.
0 commit comments