-
Notifications
You must be signed in to change notification settings - Fork 5
/
conftest.py
54 lines (41 loc) · 1.51 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""Global fixtures for MyHeat integration."""
from unittest.mock import patch
import pytest
from .const import MOCK_GET_DEVICE_INFO, MOCK_GET_DEVICES
@pytest.fixture(autouse=True)
def auto_enable_custom_integrations(enable_custom_integrations):
yield
# This fixture is used to prevent HomeAssistant from attempting to create and dismiss persistent
# notifications. These calls would fail without this fixture since the persistent_notification
# integration is never loaded during a test.
@pytest.fixture(name="skip_notifications", autouse=True)
def skip_notifications_fixture():
"""Skip notification calls."""
with patch("homeassistant.components.persistent_notification.async_create"), patch(
"homeassistant.components.persistent_notification.async_dismiss"
):
yield
@pytest.fixture
def bypass_get_device_info():
"""Skip calls to get data from API."""
with patch(
"custom_components.myheat.MhApiClient.async_get_device_info",
return_value=MOCK_GET_DEVICE_INFO["data"],
):
yield
@pytest.fixture
def bypass_get_devices():
"""Skip calls to get data from API."""
with patch(
"custom_components.myheat.MhApiClient.async_get_devices",
return_value=MOCK_GET_DEVICES["data"],
):
yield
@pytest.fixture(name="error_on_get_data")
def error_get_data_fixture():
"""Simulate error when retrieving data from API."""
with patch(
"custom_components.myheat.MhApiClient.rpc",
side_effect=Exception,
):
yield