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 11# pylint: disable=invalid-name
22
3- import pytest
4-
53import meilisearch
6- from meilisearch .errors import MeiliSearchTimeoutError
74from meilisearch .tests import BASE_URL , MASTER_KEY
85
6+
97def test_get_client ():
108 """Tests getting a client instance."""
119 client = meilisearch .Client (BASE_URL , MASTER_KEY )
@@ -15,19 +13,16 @@ def test_get_client():
1513
1614
1715def 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 )
1918 response = client .health ()
19+ assert client .config .timeout == timeout
2020 assert response .status_code >= 200 and response .status_code < 400
2121
2222
2323def test_client_timeout_not_set ():
24+ default_timeout = 10
2425 client = meilisearch .Client (BASE_URL , MASTER_KEY )
2526 response = client .health ()
27+ assert client .config .timeout == default_timeout
2628 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