hass-core/tests/components/climacell/conftest.py
Raman Gupta d0b3f76a6f
Add ClimaCell v4 API support (#47575)
* Add ClimaCell v4 API support

* fix tests

* use constants

* fix logic and update tests

* revert accidental changes and enable hourly and nowcast forecast entities in test

* use variable instead of accessing dictionary multiple times

* only grab necessary fields

* add _translate_condition method ot base class

* bump pyclimacell again to fix bug

* switch typehints back to new format

* more typehint fixes

* fix tests

* revert merge conflict change

* handle 'migration' in async_setup_entry so we don't have to bump config entry versions

* parametrize timestep test
2021-04-05 13:39:39 -04:00

51 lines
1.8 KiB
Python

"""Configure py.test."""
import json
from unittest.mock import patch
import pytest
from tests.common import load_fixture
@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(name="climacell_config_flow_connect", autouse=True)
def climacell_config_flow_connect():
"""Mock valid climacell config flow setup."""
with patch(
"homeassistant.components.climacell.config_flow.ClimaCellV3.realtime",
return_value={},
), patch(
"homeassistant.components.climacell.config_flow.ClimaCellV4.realtime",
return_value={},
):
yield
@pytest.fixture(name="climacell_config_entry_update")
def climacell_config_entry_update_fixture():
"""Mock valid climacell config entry setup."""
with patch(
"homeassistant.components.climacell.ClimaCellV3.realtime",
return_value=json.loads(load_fixture("climacell/v3_realtime.json")),
), patch(
"homeassistant.components.climacell.ClimaCellV3.forecast_hourly",
return_value=json.loads(load_fixture("climacell/v3_forecast_hourly.json")),
), patch(
"homeassistant.components.climacell.ClimaCellV3.forecast_daily",
return_value=json.loads(load_fixture("climacell/v3_forecast_daily.json")),
), patch(
"homeassistant.components.climacell.ClimaCellV3.forecast_nowcast",
return_value=json.loads(load_fixture("climacell/v3_forecast_nowcast.json")),
), patch(
"homeassistant.components.climacell.ClimaCellV4.realtime_and_all_forecasts",
return_value=json.loads(load_fixture("climacell/v4.json")),
):
yield