mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Limit log spam from rest and include reason in platform retry (#48666)
- Each retry was logging the error again - Now we set the cause of the PlatformNotReady to allow Home Assistant to log as needed
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""The tests for the REST sensor platform."""
|
||||
import asyncio
|
||||
from os import path
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import httpx
|
||||
import respx
|
||||
@@ -41,9 +41,11 @@ async def test_setup_missing_schema(hass):
|
||||
|
||||
|
||||
@respx.mock
|
||||
async def test_setup_failed_connect(hass):
|
||||
async def test_setup_failed_connect(hass, caplog):
|
||||
"""Test setup when connection error occurs."""
|
||||
respx.get("http://localhost").mock(side_effect=httpx.RequestError)
|
||||
respx.get("http://localhost").mock(
|
||||
side_effect=httpx.RequestError("server offline", request=MagicMock())
|
||||
)
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
sensor.DOMAIN,
|
||||
@@ -57,6 +59,7 @@ async def test_setup_failed_connect(hass):
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert "server offline" in caplog.text
|
||||
|
||||
|
||||
@respx.mock
|
||||
|
||||
Reference in New Issue
Block a user