2020-08-25 16:34:14 +00:00
|
|
|
"""Define fixtures available for all tests."""
|
2021-01-01 21:31:56 +00:00
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
|
2020-08-25 16:34:14 +00:00
|
|
|
from pytest import fixture
|
|
|
|
from surepy import SurePetcare
|
|
|
|
|
|
|
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|
|
|
|
|
|
|
|
2020-11-24 11:40:25 +00:00
|
|
|
@fixture
|
|
|
|
async def surepetcare(hass):
|
2020-08-25 16:34:14 +00:00
|
|
|
"""Mock the SurePetcare for easier testing."""
|
|
|
|
with patch("homeassistant.components.surepetcare.SurePetcare") as mock_surepetcare:
|
|
|
|
instance = mock_surepetcare.return_value = SurePetcare(
|
|
|
|
"test-username",
|
|
|
|
"test-password",
|
|
|
|
hass.loop,
|
|
|
|
async_get_clientsession(hass),
|
|
|
|
api_timeout=1,
|
|
|
|
)
|
2021-01-02 02:52:33 +00:00
|
|
|
instance._get_resource = AsyncMock(return_value=None)
|
2020-08-25 16:34:14 +00:00
|
|
|
yield mock_surepetcare
|