mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Surepetcare, bug fix (#55842)
This commit is contained in:
parent
9093819671
commit
bcfedeb797
@ -144,7 +144,7 @@ class SurePetcareAPI:
|
|||||||
"""Get the latest data from Sure Petcare."""
|
"""Get the latest data from Sure Petcare."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.states = await self.surepy.get_entities()
|
self.states = await self.surepy.get_entities(refresh=True)
|
||||||
except SurePetcareError as error:
|
except SurePetcareError as error:
|
||||||
_LOGGER.error("Unable to fetch data: %s", error)
|
_LOGGER.error("Unable to fetch data: %s", error)
|
||||||
return
|
return
|
||||||
|
@ -7,12 +7,16 @@ from surepy import MESTART_RESOURCE
|
|||||||
from . import MOCK_API_DATA
|
from . import MOCK_API_DATA
|
||||||
|
|
||||||
|
|
||||||
|
async def _mock_call(method, resource):
|
||||||
|
if method == "GET" and resource == MESTART_RESOURCE:
|
||||||
|
return {"data": MOCK_API_DATA}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def surepetcare():
|
async def surepetcare():
|
||||||
"""Mock the SurePetcare for easier testing."""
|
"""Mock the SurePetcare for easier testing."""
|
||||||
with patch("surepy.SureAPIClient", autospec=True) as mock_client_class, patch(
|
with patch("surepy.SureAPIClient", autospec=True) as mock_client_class:
|
||||||
"surepy.find_token"
|
|
||||||
):
|
|
||||||
client = mock_client_class.return_value
|
client = mock_client_class.return_value
|
||||||
client.resources = {MESTART_RESOURCE: {"data": MOCK_API_DATA}}
|
client.resources = {}
|
||||||
|
client.call = _mock_call
|
||||||
yield client
|
yield client
|
||||||
|
@ -12,7 +12,7 @@ EXPECTED_ENTITY_IDS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_binary_sensors(hass, surepetcare) -> None:
|
async def test_sensors(hass, surepetcare) -> None:
|
||||||
"""Test the generation of unique ids."""
|
"""Test the generation of unique ids."""
|
||||||
assert await async_setup_component(hass, DOMAIN, MOCK_CONFIG)
|
assert await async_setup_component(hass, DOMAIN, MOCK_CONFIG)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user