Do async_setup_platform in background (#36244)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Paulus Schoutsen 2020-05-31 22:18:30 -07:00 committed by GitHub
parent d488c779fc
commit 276f3afb00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
161 changed files with 1184 additions and 305 deletions

View file

@ -117,6 +117,7 @@ class TestDarkSkySetup(unittest.TestCase):
def test_setup_with_config(self):
"""Test the platform setup with configuration."""
setup_component(self.hass, "sensor", VALID_CONFIG_MINIMAL)
self.hass.block_till_done()
state = self.hass.states.get("sensor.dark_sky_summary")
assert state is not None
@ -124,6 +125,7 @@ class TestDarkSkySetup(unittest.TestCase):
def test_setup_with_invalid_config(self):
"""Test the platform setup with invalid configuration."""
setup_component(self.hass, "sensor", INVALID_CONFIG_MINIMAL)
self.hass.block_till_done()
state = self.hass.states.get("sensor.dark_sky_summary")
assert state is None
@ -135,6 +137,7 @@ class TestDarkSkySetup(unittest.TestCase):
def test_setup_with_language_config(self):
"""Test the platform setup with language configuration."""
setup_component(self.hass, "sensor", VALID_CONFIG_LANG_DE)
self.hass.block_till_done()
state = self.hass.states.get("sensor.dark_sky_summary")
assert state is not None
@ -142,6 +145,7 @@ class TestDarkSkySetup(unittest.TestCase):
def test_setup_with_invalid_language_config(self):
"""Test the platform setup with language configuration."""
setup_component(self.hass, "sensor", INVALID_CONFIG_LANG)
self.hass.block_till_done()
state = self.hass.states.get("sensor.dark_sky_summary")
assert state is None
@ -169,6 +173,7 @@ class TestDarkSkySetup(unittest.TestCase):
def test_setup_with_alerts_config(self):
"""Test the platform setup with alert configuration."""
setup_component(self.hass, "sensor", VALID_CONFIG_ALERTS)
self.hass.block_till_done()
state = self.hass.states.get("sensor.dark_sky_alerts")
assert state.state == "0"
@ -184,6 +189,7 @@ class TestDarkSkySetup(unittest.TestCase):
mock_req.get(re.compile(uri), text=load_fixture("darksky.json"))
assert setup_component(self.hass, "sensor", VALID_CONFIG_MINIMAL)
self.hass.block_till_done()
assert mock_get_forecast.called
assert mock_get_forecast.call_count == 1