Do async_setup_platform in background (#36244)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Paulus SchoutsenandJ. Nick Koston authored and GitHub committed 2020-05-31 22:18:30 -07:00
1 parent d488c779fc
commit 276f3afb00
161 files changed
+1184 -305

No files matched your search

+4 -5
View File
@@ -22,13 +22,12 @@ ENTITY_CAMERA = "camera.demo_camera"
@pytest.fixture(autouse=True)
def demo_camera(hass):
async def demo_camera(hass):
"""Initialize a demo camera platform."""
hass.loop.run_until_complete(
async_setup_component(
hass, CAMERA_DOMAIN, {CAMERA_DOMAIN: {"platform": DOMAIN}}
)
assert await async_setup_component(
hass, CAMERA_DOMAIN, {CAMERA_DOMAIN: {"platform": DOMAIN}}
)
await hass.async_block_till_done()
async def test_init_state_is_streaming(hass):
+1
View File
@@ -43,6 +43,7 @@ async def setup_demo_climate(hass):
"""Initialize setup demo climate."""
hass.config.units = METRIC_SYSTEM
assert await async_setup_component(hass, DOMAIN, {"climate": {"platform": "demo"}})
await hass.async_block_till_done()
def test_setup_params(hass):
+1
View File
@@ -42,6 +42,7 @@ async def setup_comp(hass):
"""Set up demo cover component."""
with assert_setup_component(1, DOMAIN):
await async_setup_component(hass, DOMAIN, CONFIG)
await hass.async_block_till_done()
async def test_supported_features(hass, setup_comp):
+3 -4
View File
@@ -16,11 +16,10 @@ def get_entity(hass):
@pytest.fixture(autouse=True)
def setup_comp(hass):
async def setup_comp(hass):
"""Initialize components."""
hass.loop.run_until_complete(
async_setup_component(hass, fan.DOMAIN, {"fan": {"platform": "demo"}})
)
assert await async_setup_component(hass, fan.DOMAIN, {"fan": {"platform": "demo"}})
await hass.async_block_till_done()
async def test_turn_on(hass):
+4 -3
View File
@@ -24,11 +24,12 @@ ENTITY_LIGHT = "light.bed_light"
@pytest.fixture(autouse=True)
def setup_comp(hass):
async def setup_comp(hass):
"""Set up demo component."""
hass.loop.run_until_complete(
async_setup_component(hass, LIGHT_DOMAIN, {LIGHT_DOMAIN: {"platform": DOMAIN}})
assert await async_setup_component(
hass, LIGHT_DOMAIN, {LIGHT_DOMAIN: {"platform": DOMAIN}}
)
await hass.async_block_till_done()
async def test_state_attributes(hass):
+4 -3
View File
@@ -21,11 +21,12 @@ OPENABLE_LOCK = "lock.openable_lock"
@pytest.fixture(autouse=True)
def setup_comp(hass):
async def setup_comp(hass):
"""Set up demo component."""
hass.loop.run_until_complete(
async_setup_component(hass, LOCK_DOMAIN, {LOCK_DOMAIN: {"platform": DOMAIN}})
assert await async_setup_component(
hass, LOCK_DOMAIN, {LOCK_DOMAIN: {"platform": DOMAIN}}
)
await hass.async_block_till_done()
async def test_locking(hass):
@@ -29,6 +29,7 @@ async def test_source_select(hass):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert state.attributes.get("source") == "dvd"
@@ -47,6 +48,7 @@ async def test_clear_playlist(hass):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
assert hass.states.is_state(TEST_ENTITY_ID, "playing")
await common.async_clear_playlist(hass, TEST_ENTITY_ID)
@@ -58,6 +60,7 @@ async def test_volume_services(hass):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
state = hass.states.get(TEST_ENTITY_ID)
assert state.attributes.get("volume_level") == 1.0
@@ -95,6 +98,7 @@ async def test_turning_off_and_on(hass):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
assert hass.states.is_state(TEST_ENTITY_ID, "playing")
await common.async_turn_off(hass, TEST_ENTITY_ID)
@@ -114,6 +118,7 @@ async def test_playing_pausing(hass):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
assert hass.states.is_state(TEST_ENTITY_ID, "playing")
await common.async_media_pause(hass, TEST_ENTITY_ID)
@@ -134,6 +139,7 @@ async def test_prev_next_track(hass):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
state = hass.states.get(TEST_ENTITY_ID)
assert state.attributes.get("media_track") == 1
@@ -152,6 +158,7 @@ async def test_prev_next_track(hass):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
ent_id = "media_player.lounge_room"
state = hass.states.get(ent_id)
assert state.attributes.get("media_episode") == 1
@@ -170,6 +177,7 @@ async def test_play_media(hass):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
ent_id = "media_player.living_room"
state = hass.states.get(ent_id)
assert mp.SUPPORT_PLAY_MEDIA & state.attributes.get("supported_features") > 0
@@ -192,6 +200,7 @@ async def test_seek(hass, mock_media_seek):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
ent_id = "media_player.living_room"
state = hass.states.get(ent_id)
assert state.attributes["supported_features"] & mp.SUPPORT_SEEK
@@ -209,6 +218,7 @@ async def test_media_image_proxy(hass, hass_client):
assert await async_setup_component(
hass, mp.DOMAIN, {"media_player": {"platform": "demo"}}
)
await hass.async_block_till_done()
fake_picture_data = "test.test"
+1
View File
@@ -22,6 +22,7 @@ class TestDemoRemote(unittest.TestCase):
assert setup_component(
self.hass, remote.DOMAIN, {"remote": {"platform": "demo"}}
)
self.hass.block_till_done()
# pylint: disable=invalid-name
def tearDown(self):
+3 -4
View File
@@ -6,11 +6,10 @@ from homeassistant.setup import async_setup_component
@pytest.fixture(autouse=True)
def setup_comp(hass):
async def setup_comp(hass):
"""Set up demo component."""
hass.loop.run_until_complete(
async_setup_component(hass, stt.DOMAIN, {"stt": {"platform": "demo"}})
)
assert await async_setup_component(hass, stt.DOMAIN, {"stt": {"platform": "demo"}})
await hass.async_block_till_done()
async def test_demo_settings(hass_client):
+1
View File
@@ -51,6 +51,7 @@ ENTITY_VACUUM_STATE = f"{DOMAIN}.{DEMO_VACUUM_STATE}".lower()
async def setup_demo_vacuum(hass):
"""Initialize setup demo vacuum."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "demo"}})
await hass.async_block_till_done()
async def test_supported_features(hass):
+4 -5
View File
@@ -13,14 +13,13 @@ ENTITY_WATER_HEATER_CELSIUS = "water_heater.demo_water_heater_celsius"
@pytest.fixture(autouse=True)
def setup_comp(hass):
async def setup_comp(hass):
"""Set up demo component."""
hass.config.units = IMPERIAL_SYSTEM
hass.loop.run_until_complete(
async_setup_component(
hass, water_heater.DOMAIN, {"water_heater": {"platform": "demo"}}
)
assert await async_setup_component(
hass, water_heater.DOMAIN, {"water_heater": {"platform": "demo"}}
)
await hass.async_block_till_done()
async def test_setup_params(hass):