Surepetcare, bug fix (#55842)
parent
9093819671
commit
bcfedeb797
|
@ -144,7 +144,7 @@ class SurePetcareAPI:
|
|||
"""Get the latest data from Sure Petcare."""
|
||||
|
||||
try:
|
||||
self.states = await self.surepy.get_entities()
|
||||
self.states = await self.surepy.get_entities(refresh=True)
|
||||
except SurePetcareError as error:
|
||||
_LOGGER.error("Unable to fetch data: %s", error)
|
||||
return
|
||||
|
|
|
@ -7,12 +7,16 @@ from surepy import MESTART_RESOURCE
|
|||
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
|
||||
async def surepetcare():
|
||||
"""Mock the SurePetcare for easier testing."""
|
||||
with patch("surepy.SureAPIClient", autospec=True) as mock_client_class, patch(
|
||||
"surepy.find_token"
|
||||
):
|
||||
with patch("surepy.SureAPIClient", autospec=True) as mock_client_class:
|
||||
client = mock_client_class.return_value
|
||||
client.resources = {MESTART_RESOURCE: {"data": MOCK_API_DATA}}
|
||||
client.resources = {}
|
||||
client.call = _mock_call
|
||||
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."""
|
||||
assert await async_setup_component(hass, DOMAIN, MOCK_CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Reference in New Issue