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

@@ -54,6 +54,7 @@ async def test_template_state_text(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -136,6 +137,7 @@ async def test_optimistic_states(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -189,6 +191,7 @@ async def test_no_action_scripts(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -261,6 +264,7 @@ async def test_template_syntax_error(hass, caplog):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -305,6 +309,7 @@ async def test_invalid_name_does_not_create(hass, caplog):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -325,6 +330,7 @@ async def test_invalid_panel_does_not_create(hass, caplog):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -338,6 +344,7 @@ async def test_no_panels_does_not_create(hass, caplog):
hass, "alarm_control_panel", {"alarm_control_panel": {"platform": "template"}},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -383,6 +390,7 @@ async def test_name(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -425,6 +433,7 @@ async def test_arm_home_action(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -471,6 +480,7 @@ async def test_arm_away_action(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -517,6 +527,7 @@ async def test_arm_night_action(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -563,6 +574,7 @@ async def test_disarm_action(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -127,6 +127,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -161,6 +162,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -193,6 +195,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -224,6 +227,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
init_calls = len(_async_render.mock_calls)
@@ -280,6 +284,7 @@ class TestBinarySensorTemplate(unittest.TestCase):
with assert_setup_component(1):
assert setup.setup_component(self.hass, "binary_sensor", config)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -335,6 +340,7 @@ async def test_template_delay_on(hass):
}
}
await setup.async_setup_component(hass, "binary_sensor", config)
await hass.async_block_till_done()
await hass.async_start()
hass.states.async_set("sensor.test_state", "on")
@@ -394,6 +400,7 @@ async def test_template_delay_off(hass):
}
hass.states.async_set("sensor.test_state", "on")
await setup.async_setup_component(hass, "binary_sensor", config)
await hass.async_block_till_done()
await hass.async_start()
hass.states.async_set("sensor.test_state", "off")
@@ -452,6 +459,7 @@ async def test_available_without_availability_template(hass):
}
}
await setup.async_setup_component(hass, "binary_sensor", config)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -475,6 +483,7 @@ async def test_availability_template(hass):
}
}
await setup.async_setup_component(hass, "binary_sensor", config)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -537,7 +546,7 @@ async def test_invalid_availability_template_keeps_component_available(hass, cap
}
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
+23
View File
@@ -62,6 +62,7 @@ async def test_template_state_text(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -104,6 +105,7 @@ async def test_template_state_boolean(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -137,6 +139,7 @@ async def test_template_position(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -192,6 +195,7 @@ async def test_template_tilt(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -226,6 +230,7 @@ async def test_template_out_of_bounds(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -264,6 +269,7 @@ async def test_template_mutex(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -310,6 +316,7 @@ async def test_template_open_and_close(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -347,6 +354,7 @@ async def test_template_non_numeric(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -378,6 +386,7 @@ async def test_open_action(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -416,6 +425,7 @@ async def test_close_stop_action(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -463,6 +473,7 @@ async def test_set_position(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -537,6 +548,7 @@ async def test_set_tilt_position(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -578,6 +590,7 @@ async def test_open_tilt_action(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -616,6 +629,7 @@ async def test_close_tilt_action(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -644,6 +658,7 @@ async def test_set_position_optimistic(hass, calls):
}
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -708,6 +723,7 @@ async def test_set_tilt_position_optimistic(hass, calls):
}
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -782,6 +798,7 @@ async def test_icon_template(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -825,6 +842,7 @@ async def test_entity_picture_template(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -866,6 +884,7 @@ async def test_availability_template(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -905,6 +924,7 @@ async def test_availability_without_availability_template(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -938,6 +958,7 @@ async def test_invalid_availability_template_keeps_component_available(hass, cap
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -972,6 +993,7 @@ async def test_device_class(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -1006,6 +1028,7 @@ async def test_invalid_device_class(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
+11
View File
@@ -63,6 +63,7 @@ async def test_missing_optional_config(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -88,6 +89,7 @@ async def test_missing_value_template_config(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -113,6 +115,7 @@ async def test_missing_turn_on_config(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -138,6 +141,7 @@ async def test_missing_turn_off_config(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -161,6 +165,7 @@ async def test_invalid_config(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -202,6 +207,7 @@ async def test_templates_with_entities(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -241,6 +247,7 @@ async def test_availability_template_with_entities(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -282,6 +289,7 @@ async def test_templates_with_valid_values(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -311,6 +319,7 @@ async def test_templates_invalid_values(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -342,6 +351,7 @@ async def test_invalid_availability_template_keeps_component_available(hass, cap
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -687,5 +697,6 @@ async def _register_components(hass, speed_list=None):
{"fan": {"platform": "template", "fans": {"test_fan": test_fan_config}}},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
+25
View File
@@ -78,6 +78,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -117,6 +118,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -169,6 +171,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -208,6 +211,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -246,6 +250,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -265,6 +270,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -277,6 +283,7 @@ class TestTemplateLight:
self.hass, "light", {"light": {"platform": "template"}}
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -316,6 +323,7 @@ class TestTemplateLight:
del light["light"]["lights"]["light_one"][missing_key]
with assert_setup_component(count, "light"):
assert setup.setup_component(self.hass, "light", light)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -353,6 +361,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -395,6 +404,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -440,6 +450,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -482,6 +493,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -526,6 +538,7 @@ class TestTemplateLight:
}
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -587,6 +600,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -625,6 +639,7 @@ class TestTemplateLight:
}
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -685,6 +700,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -737,6 +753,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -775,6 +792,7 @@ class TestTemplateLight:
}
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -825,6 +843,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -870,6 +889,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -920,6 +940,7 @@ class TestTemplateLight:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -975,6 +996,7 @@ class TestTemplateLight:
}
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -1046,6 +1068,7 @@ class TestTemplateLight:
}
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
state = self.hass.states.get("light.test_template_light")
@@ -1084,6 +1107,7 @@ async def test_available_template_with_entities(hass):
}
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -1134,6 +1158,7 @@ async def test_invalid_availability_template_keeps_component_available(hass, cap
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
+12
View File
@@ -57,6 +57,7 @@ class TestTemplateLock:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -94,6 +95,7 @@ class TestTemplateLock:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -122,6 +124,7 @@ class TestTemplateLock:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -150,6 +153,7 @@ class TestTemplateLock:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -178,6 +182,7 @@ class TestTemplateLock:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -192,6 +197,7 @@ class TestTemplateLock:
{"lock": {"platform": "template", "value_template": "Invalid"}},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -219,6 +225,7 @@ class TestTemplateLock:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -246,6 +253,7 @@ class TestTemplateLock:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -281,6 +289,7 @@ class TestTemplateLock:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -315,6 +324,7 @@ class TestTemplateLock:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -352,6 +362,7 @@ async def test_available_template_with_entities(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -389,6 +400,7 @@ async def test_invalid_availability_template_keeps_component_available(hass, cap
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
+16
View File
@@ -42,6 +42,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -75,6 +76,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -108,6 +110,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -138,6 +141,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -168,6 +172,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -200,6 +205,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -229,6 +235,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
assert self.hass.states.all() == []
@@ -252,6 +259,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -276,6 +284,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -295,6 +304,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
assert self.hass.states.all() == []
@@ -306,6 +316,7 @@ class TestTemplateSensor:
self.hass, "sensor", {"sensor": {"platform": "template"}}
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -329,6 +340,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -401,6 +413,7 @@ class TestTemplateSensor:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -445,6 +458,7 @@ async def test_available_template_with_entities(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -510,6 +524,7 @@ async def test_invalid_availability_template_keeps_component_available(hass, cap
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -549,6 +564,7 @@ async def test_no_template_match_all(hass, caplog):
}
},
)
await hass.async_block_till_done()
assert hass.states.get("sensor.invalid_state").state == "unknown"
assert hass.states.get("sensor.invalid_icon").state == "unknown"
+16
View File
@@ -56,6 +56,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -97,6 +98,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -129,6 +131,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -164,6 +167,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -205,6 +209,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -243,6 +248,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -274,6 +280,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -293,6 +300,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -305,6 +313,7 @@ class TestTemplateSwitch:
self.hass, "switch", {"switch": {"platform": "template"}}
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -336,6 +345,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -367,6 +377,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -398,6 +409,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -425,6 +437,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -461,6 +474,7 @@ class TestTemplateSwitch:
},
)
self.hass.block_till_done()
self.hass.start()
self.hass.block_till_done()
@@ -502,6 +516,7 @@ async def test_available_template_with_entities(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -542,6 +557,7 @@ async def test_invalid_availability_template_keeps_component_available(hass, cap
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
+11
View File
@@ -50,6 +50,7 @@ async def test_missing_optional_config(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -70,6 +71,7 @@ async def test_missing_start_config(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -90,6 +92,7 @@ async def test_invalid_config(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -120,6 +123,7 @@ async def test_templates_with_entities(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -152,6 +156,7 @@ async def test_templates_with_valid_values(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -178,6 +183,7 @@ async def test_templates_invalid_values(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -205,6 +211,7 @@ async def test_invalid_templates(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -230,6 +237,7 @@ async def test_available_template_with_entities(hass, calls):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -266,6 +274,7 @@ async def test_invalid_availability_template_keeps_component_available(hass, cap
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -446,6 +455,7 @@ async def _register_basic_vacuum(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()
@@ -532,5 +542,6 @@ async def _register_components(hass):
},
)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till_done()