From 2360fd414126ba38f6e243b6a8b89adaae7abc50 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Mar 2020 13:27:45 -0500 Subject: [PATCH] =?UTF-8?q?Switch=20legacy=20calls=20to=20init=5Frecorder?= =?UTF-8?q?=5Fcomponent=20using=20async=5Fadd=E2=80=A6=20(#33185)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/components/doorbird/test_config_flow.py | 24 ++++++++++++++----- tests/components/history/test_init.py | 4 ++-- tests/components/logbook/test_init.py | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/components/doorbird/test_config_flow.py b/tests/components/doorbird/test_config_flow.py index 7a70aec9041..009062d0193 100644 --- a/tests/components/doorbird/test_config_flow.py +++ b/tests/components/doorbird/test_config_flow.py @@ -36,7 +36,9 @@ def _get_mock_doorbirdapi_side_effects(ready=None, info=None): async def test_user_form(hass): """Test we get the user form.""" - await hass.async_add_job(init_recorder_component, hass) # force in memory db + await hass.async_add_executor_job( + init_recorder_component, hass + ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( @@ -75,7 +77,9 @@ async def test_user_form(hass): async def test_form_import(hass): """Test we get the form with import source.""" - await hass.async_add_job(init_recorder_component, hass) # force in memory db + await hass.async_add_executor_job( + init_recorder_component, hass + ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) @@ -125,7 +129,9 @@ async def test_form_import(hass): async def test_form_zeroconf_wrong_oui(hass): """Test we abort when we get the wrong OUI via zeroconf.""" - await hass.async_add_job(init_recorder_component, hass) # force in memory db + await hass.async_add_executor_job( + init_recorder_component, hass + ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) @@ -142,7 +148,9 @@ async def test_form_zeroconf_wrong_oui(hass): async def test_form_zeroconf_correct_oui(hass): """Test we can setup from zeroconf with the correct OUI source.""" - await hass.async_add_job(init_recorder_component, hass) # force in memory db + await hass.async_add_executor_job( + init_recorder_component, hass + ) # force in memory db await setup.async_setup_component(hass, "persistent_notification", {}) @@ -188,7 +196,9 @@ async def test_form_zeroconf_correct_oui(hass): async def test_form_user_cannot_connect(hass): """Test we handle cannot connect error.""" - await hass.async_add_job(init_recorder_component, hass) # force in memory db + await hass.async_add_executor_job( + init_recorder_component, hass + ) # force in memory db result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} @@ -209,7 +219,9 @@ async def test_form_user_cannot_connect(hass): async def test_form_user_invalid_auth(hass): """Test we handle cannot invalid auth error.""" - await hass.async_add_job(init_recorder_component, hass) # force in memory db + await hass.async_add_executor_job( + init_recorder_component, hass + ) # force in memory db result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} diff --git a/tests/components/history/test_init.py b/tests/components/history/test_init.py index 65c0a717bee..51f1e3cb2ac 100644 --- a/tests/components/history/test_init.py +++ b/tests/components/history/test_init.py @@ -617,7 +617,7 @@ class TestComponentHistory(unittest.TestCase): async def test_fetch_period_api(hass, hass_client): """Test the fetch period view for history.""" - await hass.async_add_job(init_recorder_component, hass) + await hass.async_add_executor_job(init_recorder_component, hass) await async_setup_component(hass, "history", {}) await hass.async_add_job(hass.data[recorder.DATA_INSTANCE].block_till_done) client = await hass_client() @@ -629,7 +629,7 @@ async def test_fetch_period_api(hass, hass_client): async def test_fetch_period_api_with_include_order(hass, hass_client): """Test the fetch period view for history.""" - await hass.async_add_job(init_recorder_component, hass) + await hass.async_add_executor_job(init_recorder_component, hass) await async_setup_component( hass, "history", diff --git a/tests/components/logbook/test_init.py b/tests/components/logbook/test_init.py index 98653dc5a6c..cc07d6cf40f 100644 --- a/tests/components/logbook/test_init.py +++ b/tests/components/logbook/test_init.py @@ -1270,7 +1270,7 @@ class TestComponentLogbook(unittest.TestCase): async def test_logbook_view(hass, hass_client): """Test the logbook view.""" - await hass.async_add_job(init_recorder_component, hass) + await hass.async_add_executor_job(init_recorder_component, hass) await async_setup_component(hass, "logbook", {}) await hass.async_add_job(hass.data[recorder.DATA_INSTANCE].block_till_done) client = await hass_client() @@ -1280,7 +1280,7 @@ async def test_logbook_view(hass, hass_client): async def test_logbook_view_period_entity(hass, hass_client): """Test the logbook view with period and entity.""" - await hass.async_add_job(init_recorder_component, hass) + await hass.async_add_executor_job(init_recorder_component, hass) await async_setup_component(hass, "logbook", {}) await hass.async_add_job(hass.data[recorder.DATA_INSTANCE].block_till_done)