Replace periodic tasks with background tasks (#112726)

* Phase out periodic tasks

* false by default or some tests will block forever, will need to fix each one manually

* kwarg works

* kwarg works

* kwarg works

* fixes

* fix more tests

* fix more tests

* fix lifx

* opensky

* pvpc_hourly_pricing

* adjust more

* adjust more

* smarttub

* adjust more

* adjust more

* adjust more

* adjust more

* adjust

* no eager executor

* zha

* qnap_qsw

* fix more

* fix fix

* docs

* its a wrapper now

* add more coverage

* coverage

* cover all combos

* more fixes

* more fixes

* more fixes

* remaining issues are legit bugs in tests

* make tplink test more predictable

* more fixes

* feedreader

* grind out some more

* make test race safe

* one more
This commit is contained in:
J. Nick Koston 2024-03-08 16:45:10 -10:00 committed by GitHub
parent 08416974c9
commit 65358c129a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 413 additions and 333 deletions

View file

@ -248,7 +248,7 @@ async def test_invalid_url_on_update(
hass,
dt_util.utcnow() + timedelta(minutes=1),
)
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
assert "sqlite://****:****@homeassistant.local" in caplog.text
@ -287,7 +287,7 @@ async def test_templates_with_yaml(
hass,
dt_util.utcnow() + timedelta(minutes=1),
)
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
state = hass.states.get("sensor.get_values_with_template")
assert state.state == "5"
@ -301,7 +301,7 @@ async def test_templates_with_yaml(
hass,
dt_util.utcnow() + timedelta(minutes=2),
)
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
state = hass.states.get("sensor.get_values_with_template")
assert state.state == STATE_UNAVAILABLE
@ -314,7 +314,7 @@ async def test_templates_with_yaml(
hass,
dt_util.utcnow() + timedelta(minutes=3),
)
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
state = hass.states.get("sensor.get_values_with_template")
assert state.state == "5"
@ -488,7 +488,7 @@ async def test_no_issue_when_view_has_the_text_entity_id_in_it(
hass,
dt_util.utcnow() + timedelta(minutes=1),
)
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
assert (
"Query contains entity_id but does not reference states_meta" not in caplog.text
@ -622,7 +622,7 @@ async def test_query_recover_from_rollback(
):
freezer.tick(timedelta(minutes=1))
async_fire_time_changed(hass)
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
assert "sqlite3.OperationalError" in caplog.text
state = hass.states.get("sensor.select_value_sql_query")
@ -631,7 +631,7 @@ async def test_query_recover_from_rollback(
freezer.tick(timedelta(minutes=1))
async_fire_time_changed(hass)
await hass.async_block_till_done()
await hass.async_block_till_done(wait_background_tasks=True)
state = hass.states.get("sensor.select_value_sql_query")
assert state.state == "5"