hass-core/tests/components/tomorrowio/conftest.py
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00

40 lines
1.3 KiB
Python

"""Configure py.test."""
import json
from unittest.mock import PropertyMock, patch
import pytest
from tests.common import load_fixture
@pytest.fixture(name="tomorrowio_config_flow_connect", autouse=True)
def tomorrowio_config_flow_connect():
"""Mock valid tomorrowio config flow setup."""
with patch(
"homeassistant.components.tomorrowio.config_flow.TomorrowioV4.realtime",
return_value={},
):
yield
@pytest.fixture(name="tomorrowio_config_entry_update", autouse=True)
def tomorrowio_config_entry_update_fixture():
"""Mock valid tomorrowio config entry setup."""
with (
patch(
"homeassistant.components.tomorrowio.TomorrowioV4.realtime_and_all_forecasts",
return_value=json.loads(load_fixture("v4.json", "tomorrowio")),
) as mock_update,
patch(
"homeassistant.components.tomorrowio.TomorrowioV4.max_requests_per_day",
new_callable=PropertyMock,
) as mock_max_requests_per_day,
patch(
"homeassistant.components.tomorrowio.TomorrowioV4.num_api_requests",
new_callable=PropertyMock,
) as mock_num_api_requests,
):
mock_max_requests_per_day.return_value = 100
mock_num_api_requests.return_value = 2
yield mock_update