Deprecated stuff (#16019)

* Use async with for locks

* Fix regex in template test

* Close session correctly

* Use correct current_task method

* push camera cleanup

* Lint

* Revert current_task

* Update websocket_api.py

* Mock executor_job betteR

* Fix async_create_task mock
This commit is contained in:
Paulus Schoutsen 2018-08-20 16:34:18 +02:00 committed by GitHub
parent 975befd136
commit d1e1b9b38a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 22 deletions

View file

@ -123,14 +123,30 @@ def async_test_home_assistant(loop):
INSTANCES.append(hass)
orig_async_add_job = hass.async_add_job
orig_async_add_executor_job = hass.async_add_executor_job
orig_async_create_task = hass.async_create_task
def async_add_job(target, *args):
"""Add a magic mock."""
"""Add job."""
if isinstance(target, Mock):
return mock_coro(target(*args))
return orig_async_add_job(target, *args)
def async_add_executor_job(target, *args):
"""Add executor job."""
if isinstance(target, Mock):
return mock_coro(target(*args))
return orig_async_add_executor_job(target, *args)
def async_create_task(coroutine):
"""Create task."""
if isinstance(coroutine, Mock):
return mock_coro()
return orig_async_create_task(coroutine)
hass.async_add_job = async_add_job
hass.async_add_executor_job = async_add_executor_job
hass.async_create_task = async_create_task
hass.config.location_name = 'test home'
hass.config.config_dir = get_test_config_dir()