2020-08-25 16:34:14 +00:00
|
|
|
"""Define fixtures available for all tests."""
|
2021-04-27 18:58:52 +00:00
|
|
|
from unittest.mock import patch
|
2021-01-01 21:31:56 +00:00
|
|
|
|
2021-04-27 18:58:52 +00:00
|
|
|
import pytest
|
|
|
|
from surepy import MESTART_RESOURCE
|
2020-08-25 16:34:14 +00:00
|
|
|
|
2021-04-27 18:58:52 +00:00
|
|
|
from . import MOCK_API_DATA
|
2020-08-25 16:34:14 +00:00
|
|
|
|
|
|
|
|
2021-09-06 20:36:45 +00:00
|
|
|
async def _mock_call(method, resource):
|
|
|
|
if method == "GET" and resource == MESTART_RESOURCE:
|
|
|
|
return {"data": MOCK_API_DATA}
|
|
|
|
|
|
|
|
|
2021-04-27 18:58:52 +00:00
|
|
|
@pytest.fixture
|
|
|
|
async def surepetcare():
|
2020-08-25 16:34:14 +00:00
|
|
|
"""Mock the SurePetcare for easier testing."""
|
2021-09-06 20:36:45 +00:00
|
|
|
with patch("surepy.SureAPIClient", autospec=True) as mock_client_class:
|
2021-04-27 18:58:52 +00:00
|
|
|
client = mock_client_class.return_value
|
2021-09-06 20:36:45 +00:00
|
|
|
client.resources = {}
|
|
|
|
client.call = _mock_call
|
2021-09-13 19:57:06 +00:00
|
|
|
client.get_token.return_value = "token"
|
2021-04-27 18:58:52 +00:00
|
|
|
yield client
|