File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 11"""Test for the Glances API client."""
2-
Original file line number Diff line number Diff line change 1+ """Test the interaction with the currencylayer API."""
2+ 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" )
You can’t perform that action at this time.
0 commit comments