2020-10-21 14:09:00 +00:00
|
|
|
"""Define fixtures available for all tests."""
|
2024-03-08 13:50:25 +00:00
|
|
|
|
2024-07-01 09:58:49 +00:00
|
|
|
from collections.abc import Generator
|
2024-06-24 16:55:36 +00:00
|
|
|
from unittest.mock import MagicMock, patch
|
2021-01-01 21:31:56 +00:00
|
|
|
|
2023-01-27 08:09:46 +00:00
|
|
|
import pytest
|
2020-10-21 14:09:00 +00:00
|
|
|
|
2024-06-24 16:55:36 +00:00
|
|
|
from . import get_mock_client
|
2020-10-21 14:09:00 +00:00
|
|
|
|
|
|
|
|
2023-01-27 08:09:46 +00:00
|
|
|
@pytest.fixture
|
2024-06-24 16:55:36 +00:00
|
|
|
def cfupdate() -> Generator[MagicMock]:
|
2020-10-21 14:09:00 +00:00
|
|
|
"""Mock the CloudflareUpdater for easier testing."""
|
2024-06-24 16:55:36 +00:00
|
|
|
mock_cfupdate = get_mock_client()
|
2020-10-21 14:09:00 +00:00
|
|
|
with patch(
|
2023-11-06 10:05:44 +00:00
|
|
|
"homeassistant.components.cloudflare.pycfdns.Client",
|
2020-10-21 14:09:00 +00:00
|
|
|
return_value=mock_cfupdate,
|
|
|
|
) as mock_api:
|
|
|
|
yield mock_api
|
|
|
|
|
|
|
|
|
2023-01-27 08:09:46 +00:00
|
|
|
@pytest.fixture
|
2024-06-24 16:55:36 +00:00
|
|
|
def cfupdate_flow() -> Generator[MagicMock]:
|
2020-10-21 14:09:00 +00:00
|
|
|
"""Mock the CloudflareUpdater for easier config flow testing."""
|
2024-06-24 16:55:36 +00:00
|
|
|
mock_cfupdate = get_mock_client()
|
2020-10-21 14:09:00 +00:00
|
|
|
with patch(
|
2024-06-24 16:55:36 +00:00
|
|
|
"homeassistant.components.cloudflare.config_flow.pycfdns.Client",
|
2020-10-21 14:09:00 +00:00
|
|
|
return_value=mock_cfupdate,
|
|
|
|
) as mock_api:
|
|
|
|
yield mock_api
|