mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Fix flakey influxdb test (#115442)
This commit is contained in:
parent
cfda8f64b4
commit
e3680044fe
@ -1,5 +1,6 @@
|
|||||||
"""The tests for the InfluxDB component."""
|
"""The tests for the InfluxDB component."""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import datetime
|
import datetime
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
@ -1572,12 +1573,21 @@ async def test_invalid_inputs_error(
|
|||||||
await _setup(hass, mock_client, config_ext, get_write_api)
|
await _setup(hass, mock_client, config_ext, get_write_api)
|
||||||
|
|
||||||
write_api = get_write_api(mock_client)
|
write_api = get_write_api(mock_client)
|
||||||
write_api.side_effect = test_exception
|
|
||||||
|
write_api_done_event = asyncio.Event()
|
||||||
|
|
||||||
|
def wait_for_write(*args, **kwargs):
|
||||||
|
hass.loop.call_soon_threadsafe(write_api_done_event.set)
|
||||||
|
raise test_exception
|
||||||
|
|
||||||
|
write_api.side_effect = wait_for_write
|
||||||
|
|
||||||
with patch(f"{INFLUX_PATH}.time.sleep") as sleep:
|
with patch(f"{INFLUX_PATH}.time.sleep") as sleep:
|
||||||
|
write_api_done_event.clear()
|
||||||
hass.states.async_set("fake.something", 1)
|
hass.states.async_set("fake.something", 1)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await async_wait_for_queue_to_process(hass)
|
await async_wait_for_queue_to_process(hass)
|
||||||
|
await write_api_done_event.wait()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
write_api.assert_called_once()
|
write_api.assert_called_once()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user