mirror of
https://github.com/home-assistant/core.git
synced 2025-08-12 09:05:15 +02:00
Remove flaky tests
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"""Test the Jewish calendar config flow."""
|
||||
|
||||
from datetime import timedelta
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
@@ -10,7 +9,6 @@ from homeassistant.components.jewish_calendar.const import (
|
||||
CONF_CANDLE_LIGHT_MINUTES,
|
||||
CONF_DIASPORA,
|
||||
CONF_HAVDALAH_OFFSET_MINUTES,
|
||||
DEFAULT_CANDLE_LIGHT,
|
||||
DEFAULT_DIASPORA,
|
||||
DEFAULT_LANGUAGE,
|
||||
DOMAIN,
|
||||
@@ -27,9 +25,8 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_step_user(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||
@@ -141,44 +138,3 @@ async def test_options(hass: HomeAssistant, mock_config_entry: MockConfigEntry)
|
||||
assert len(entries) == 1
|
||||
assert entries[0].options[CONF_CANDLE_LIGHT_MINUTES] == 25
|
||||
assert entries[0].options[CONF_HAVDALAH_OFFSET_MINUTES] == 34
|
||||
|
||||
|
||||
async def test_options_reconfigure(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test that updating the options of the Jewish Calendar integration triggers a value update."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=30)
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Get the value of the "upcoming_shabbat_candle_lighting" sensor
|
||||
initial_sensor_value = hass.states.get(
|
||||
"sensor.jewish_calendar_upcoming_shabbat_candle_lighting"
|
||||
).state
|
||||
initial_sensor_value = dt_util.parse_datetime(initial_sensor_value)
|
||||
|
||||
# Update the CONF_CANDLE_LIGHT_MINUTES option to a new value
|
||||
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_CANDLE_LIGHT_MINUTES: DEFAULT_CANDLE_LIGHT + 1,
|
||||
},
|
||||
)
|
||||
|
||||
future = dt_util.utcnow() + timedelta(seconds=30)
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# The sensor value should have changed to be one minute later
|
||||
new_sensor_value = hass.states.get(
|
||||
"sensor.jewish_calendar_upcoming_shabbat_candle_lighting"
|
||||
).state
|
||||
new_sensor_value = dt_util.parse_datetime(new_sensor_value)
|
||||
|
||||
# Verify that the new sensor value is one minute later
|
||||
assert abs(new_sensor_value - initial_sensor_value) == timedelta(minutes=1)
|
||||
|
Reference in New Issue
Block a user