Add new tomorrow.io integration to replace Climacell (#68156)

* Add new tomorrow.io integration to replace Climacell - Part 1/3 (#57121)

* Add new tomorrow.io integration to replace Climacell - Part 1/3

* remove unused code

* remove extra test

* remove more unused code

* Remove even more unused code

* Feedback

* clean up options flow

* clean up options flow

* tweaks and fix tests

* remove device_class from tomorrowio entity description class

* use timestep

* fix tests

* always use default name but add zone name if location is in a zone

* revert change that will go into future PR

* review comments

* move code out of try block

* bump max requests to 500 as per docs

* fix tests

* Add new tomorrow.io integration to replace Climacell - Part 2/3 (#57124)

* Add new tomorrow.io integration to replace Climacell - Part 2/3

* translations

* set config flow to false in manifest

* Cleanup more code and re-add options flow test

* fixes

* patch I/O calls

* Update tests/components/climacell/test_config_flow.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* remove unused import

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Fix codeowners

* fix mypy and pylint

* Switch to DeviceInfo

* Fix fixture location and improve sensor entities in tomorrowio integration (#63527)

* Add new tomorrow.io integration to replace Climacell - Part 3/3 (#59698)

* Switch to DeviceInfo

* Add new tomorrow.io integration to replace Climacell - Part 1/3 (#57121)

* Add new tomorrow.io integration to replace Climacell - Part 1/3

* remove unused code

* remove extra test

* remove more unused code

* Remove even more unused code

* Feedback

* clean up options flow

* clean up options flow

* tweaks and fix tests

* remove device_class from tomorrowio entity description class

* use timestep

* fix tests

* always use default name but add zone name if location is in a zone

* revert change that will go into future PR

* review comments

* move code out of try block

* bump max requests to 500 as per docs

* fix tests

* Migrate ClimaCell entries to Tomorrow.io

* tweaks

* pylint

* Apply fix from #60454 to tomorrowio integration

* lint and mypy

* use speed conversion instead of distance conversion

* Use SensorDeviceClass enum

* Use built in conversions and remove unused loggers

* fix requirements

* Update homeassistant/components/tomorrowio/__init__.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Use constants

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Black

* Update logic and add coverage

* remove extra line

* Do patching correctly

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Raman Gupta 2022-03-19 03:42:22 -04:00 committed by GitHub
parent 4578de68e7
commit 4cd4fbefbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 4895 additions and 3576 deletions

View file

@ -1,16 +1,14 @@
"""Tests for Climacell init."""
from unittest.mock import patch
import pytest
from homeassistant.components.climacell.config_flow import (
_get_config_schema,
_get_unique_id,
)
from homeassistant.components.climacell.const import CONF_TIMESTEP, DOMAIN
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
from homeassistant.const import CONF_API_VERSION
from homeassistant.core import HomeAssistant
from .const import API_V3_ENTRY_DATA, MIN_CONFIG, V1_ENTRY_DATA
from .const import API_V3_ENTRY_DATA
from tests.common import MockConfigEntry
@ -20,11 +18,10 @@ async def test_load_and_unload(
climacell_config_entry_update: pytest.fixture,
) -> None:
"""Test loading and unloading entry."""
data = _get_config_schema(hass)(MIN_CONFIG)
config_entry = MockConfigEntry(
domain=DOMAIN,
data=data,
unique_id=_get_unique_id(hass, data),
data=API_V3_ENTRY_DATA,
unique_id="test",
version=1,
)
config_entry.add_to_hass(hass)
@ -42,11 +39,10 @@ async def test_v3_load_and_unload(
climacell_config_entry_update: pytest.fixture,
) -> None:
"""Test loading and unloading v3 entry."""
data = _get_config_schema(hass)(API_V3_ENTRY_DATA)
config_entry = MockConfigEntry(
domain=DOMAIN,
data=data,
unique_id=_get_unique_id(hass, data),
data={k: v for k, v in API_V3_ENTRY_DATA.items() if k != CONF_API_VERSION},
unique_id="test",
version=1,
)
config_entry.add_to_hass(hass)
@ -59,6 +55,29 @@ async def test_v3_load_and_unload(
assert len(hass.states.async_entity_ids(WEATHER_DOMAIN)) == 0
async def test_v4_load_and_unload(
hass: HomeAssistant,
climacell_config_entry_update: pytest.fixture,
) -> None:
"""Test loading and unloading v3 entry."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={
CONF_API_VERSION: 4,
**{k: v for k, v in API_V3_ENTRY_DATA.items() if k != CONF_API_VERSION},
},
unique_id="test",
version=1,
)
config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.tomorrowio.async_setup_entry", return_value=True
):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids(WEATHER_DOMAIN)) == 0
@pytest.mark.parametrize(
"old_timestep, new_timestep", [(2, 1), (7, 5), (20, 15), (21, 30)]
)
@ -71,9 +90,9 @@ async def test_migrate_timestep(
"""Test migration to standardized timestep."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data=V1_ENTRY_DATA,
data=API_V3_ENTRY_DATA,
options={CONF_TIMESTEP: old_timestep},
unique_id=_get_unique_id(hass, V1_ENTRY_DATA),
unique_id="test",
version=1,
)
config_entry.add_to_hass(hass)