Remove flaky climacell test (#47080)

This commit is contained in:
Raman Gupta 2021-02-26 07:45:21 -05:00 committed by GitHub
parent dfbb653107
commit 56673f7edf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,5 @@
"""Tests for Climacell init."""
from datetime import timedelta
import logging
from unittest.mock import patch
import pytest
@ -12,11 +10,10 @@ from homeassistant.components.climacell.config_flow import (
from homeassistant.components.climacell.const import DOMAIN
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util import dt as dt_util
from .const import MIN_CONFIG
from tests.common import MockConfigEntry, async_fire_time_changed
from tests.common import MockConfigEntry
_LOGGER = logging.getLogger(__name__)
@ -39,44 +36,3 @@ async def test_load_and_unload(
assert await hass.config_entries.async_remove(config_entry.entry_id)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids(WEATHER_DOMAIN)) == 0
async def test_update_interval(
hass: HomeAssistantType,
climacell_config_entry_update: pytest.fixture,
) -> None:
"""Test that update_interval changes based on number of entries."""
now = dt_util.utcnow()
async_fire_time_changed(hass, now)
config = _get_config_schema(hass)(MIN_CONFIG)
for i in range(1, 3):
config_entry = MockConfigEntry(
domain=DOMAIN, data=config, unique_id=_get_unique_id(hass, config) + str(i)
)
config_entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
with patch("homeassistant.components.climacell.ClimaCell.realtime") as mock_api:
# First entry refresh will happen in 7 minutes due to original update interval.
# Next refresh for this entry will happen at 20 minutes due to the update interval
# change.
mock_api.return_value = {}
async_fire_time_changed(hass, now + timedelta(minutes=7))
await hass.async_block_till_done()
assert mock_api.call_count == 1
# Second entry refresh will happen in 13 minutes due to the update interval set
# when it was set up. Next refresh for this entry will happen at 26 minutes due to the
# update interval change.
mock_api.reset_mock()
async_fire_time_changed(hass, now + timedelta(minutes=13))
await hass.async_block_till_done()
assert not mock_api.call_count == 1
# 19 minutes should be after the first update for each config entry and before the
# second update for the first config entry
mock_api.reset_mock()
async_fire_time_changed(hass, now + timedelta(minutes=19))
await hass.async_block_till_done()
assert not mock_api.call_count == 0