diff --git a/backend/tests/test_price_history.py b/backend/tests/test_price_history.py index 2dacaee..200e4a0 100644 --- a/backend/tests/test_price_history.py +++ b/backend/tests/test_price_history.py @@ -65,6 +65,22 @@ class TestFetchBtcEurPrice: ): await fetch_btc_eur_price() + @pytest.mark.asyncio + async def test_raises_on_network_error(self): + """Verify network errors (ConnectError, TimeoutException) are propagated.""" + import httpx + + mock_client = AsyncMock() + mock_client.get.side_effect = httpx.ConnectError("Connection refused") + mock_client.__aenter__.return_value = mock_client + mock_client.__aexit__.return_value = None + + with ( + patch("price_fetcher.httpx.AsyncClient", return_value=mock_client), + pytest.raises(httpx.ConnectError), + ): + await fetch_btc_eur_price() + @pytest.mark.asyncio async def test_raises_on_invalid_response_format(self): """Verify ValueError is raised for unexpected response format."""