2023-09-16 23:00:41 +09:00
|
|
|
"""Common fixtures for the SwitchBot via API tests."""
|
2024-03-08 14:47:22 +01:00
|
|
|
|
2024-07-01 11:54:42 +02:00
|
|
|
from collections.abc import Generator
|
2023-09-16 23:00:41 +09:00
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2024-10-25 14:09:14 -04:00
|
|
|
from homeassistant.components.switchbot_cloud import SwitchBotAPI
|
|
|
|
|
|
2023-09-16 23:00:41 +09:00
|
|
|
|
|
|
|
|
@pytest.fixture
|
2024-06-06 17:41:37 +02:00
|
|
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
2023-09-16 23:00:41 +09:00
|
|
|
"""Override async_setup_entry."""
|
|
|
|
|
with patch(
|
|
|
|
|
"homeassistant.components.switchbot_cloud.async_setup_entry",
|
|
|
|
|
return_value=True,
|
|
|
|
|
) as mock_setup_entry:
|
|
|
|
|
yield mock_setup_entry
|
2024-10-25 14:09:14 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def mock_list_devices():
|
|
|
|
|
"""Mock list_devices."""
|
|
|
|
|
with patch.object(SwitchBotAPI, "list_devices") as mock_list_devices:
|
|
|
|
|
yield mock_list_devices
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def mock_get_status():
|
|
|
|
|
"""Mock get_status."""
|
|
|
|
|
with patch.object(SwitchBotAPI, "get_status") as mock_get_status:
|
|
|
|
|
yield mock_get_status
|