mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
Convert test helpers to get hass instance to contextmanagers (#109990)
* Convert get_test_home_assistant helper to contextmanager * Convert async_test_home_assistant helper to contextmanager * Move timezone reset to async_test_home_assistant helper
This commit is contained in:
@@ -75,32 +75,26 @@ class MockFFmpegDev(ffmpeg.FFmpegBase):
|
||||
self.called_entities = entity_ids
|
||||
|
||||
|
||||
class TestFFmpegSetup:
|
||||
"""Test class for ffmpeg."""
|
||||
|
||||
def setup_method(self):
|
||||
"""Set up things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
|
||||
def teardown_method(self):
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_setup_component(self):
|
||||
"""Set up ffmpeg component."""
|
||||
def test_setup_component():
|
||||
"""Set up ffmpeg component."""
|
||||
with get_test_home_assistant() as hass:
|
||||
with assert_setup_component(1):
|
||||
setup_component(self.hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
assert self.hass.data[ffmpeg.DATA_FFMPEG].binary == "ffmpeg"
|
||||
assert hass.data[ffmpeg.DATA_FFMPEG].binary == "ffmpeg"
|
||||
hass.stop()
|
||||
|
||||
def test_setup_component_test_service(self):
|
||||
"""Set up ffmpeg component test services."""
|
||||
|
||||
def test_setup_component_test_service():
|
||||
"""Set up ffmpeg component test services."""
|
||||
with get_test_home_assistant() as hass:
|
||||
with assert_setup_component(1):
|
||||
setup_component(self.hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
setup_component(hass, ffmpeg.DOMAIN, {ffmpeg.DOMAIN: {}})
|
||||
|
||||
assert self.hass.services.has_service(ffmpeg.DOMAIN, "start")
|
||||
assert self.hass.services.has_service(ffmpeg.DOMAIN, "stop")
|
||||
assert self.hass.services.has_service(ffmpeg.DOMAIN, "restart")
|
||||
assert hass.services.has_service(ffmpeg.DOMAIN, "start")
|
||||
assert hass.services.has_service(ffmpeg.DOMAIN, "stop")
|
||||
assert hass.services.has_service(ffmpeg.DOMAIN, "restart")
|
||||
hass.stop()
|
||||
|
||||
|
||||
async def test_setup_component_test_register(hass: HomeAssistant) -> None:
|
||||
|
||||
Reference in New Issue
Block a user