We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 656004e commit 119fda9Copy full SHA for 119fda9
2 files changed
tests/__init__.py
@@ -1,2 +1 @@
1
"""Test for the Glances API client."""
2
-
tests/test_timeout.py
@@ -0,0 +1,23 @@
+"""Test the interaction with the currencylayer API."""
+import pytest
3
+from pytest_httpx import HTTPXMock
4
+
5
+from glances_api import Glances
6
+import httpx
7
8
9
+@pytest.mark.asyncio
10
+async def test_timeout(httpx_mock: HTTPXMock):
11
+ """Test if the connection is hitting the timeout."""
12
13
+ def raise_timeout(request, extensions: dict):
14
+ """Set the timeout for the requests."""
15
+ raise httpx.ReadTimeout(
16
+ f"Unable to read within {extensions['timeout']}", request=request
17
+ )
18
19
+ httpx_mock.add_callback(raise_timeout)
20
21
+ with pytest.raises(httpx.ReadTimeout):
22
+ client = Glances()
23
+ await client.get_metrics("mem")
0 commit comments