Remove async_add_job from system_log tests (#41551)

This commit is contained in:
J. Nick Koston 2020-10-09 08:50:43 -05:00 committed by GitHub
parent 078ecef4b2
commit 61262222aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -230,9 +230,7 @@ async def test_clear_logs(hass, simple_queue, hass_client):
_LOGGER.error("error message")
await _async_block_until_queue_empty(hass, simple_queue)
hass.async_add_job(
hass.services.async_call(system_log.DOMAIN, system_log.SERVICE_CLEAR, {})
)
await hass.services.async_call(system_log.DOMAIN, system_log.SERVICE_CLEAR, {})
await _async_block_until_queue_empty(hass, simple_queue)
# Assert done by get_error_log
@ -244,10 +242,8 @@ async def test_write_log(hass):
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
logger = MagicMock()
with patch("logging.getLogger", return_value=logger) as mock_logging:
hass.async_add_job(
hass.services.async_call(
system_log.DOMAIN, system_log.SERVICE_WRITE, {"message": "test_message"}
)
await hass.services.async_call(
system_log.DOMAIN, system_log.SERVICE_WRITE, {"message": "test_message"}
)
await hass.async_block_till_done()
mock_logging.assert_called_once_with("homeassistant.components.system_log.external")
@ -258,12 +254,10 @@ async def test_write_choose_logger(hass):
"""Test that correct logger is chosen."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
with patch("logging.getLogger") as mock_logging:
hass.async_add_job(
hass.services.async_call(
system_log.DOMAIN,
system_log.SERVICE_WRITE,
{"message": "test_message", "logger": "myLogger"},
)
await hass.services.async_call(
system_log.DOMAIN,
system_log.SERVICE_WRITE,
{"message": "test_message", "logger": "myLogger"},
)
await hass.async_block_till_done()
mock_logging.assert_called_once_with("myLogger")
@ -274,12 +268,10 @@ async def test_write_choose_level(hass):
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
logger = MagicMock()
with patch("logging.getLogger", return_value=logger):
hass.async_add_job(
hass.services.async_call(
system_log.DOMAIN,
system_log.SERVICE_WRITE,
{"message": "test_message", "level": "debug"},
)
await hass.services.async_call(
system_log.DOMAIN,
system_log.SERVICE_WRITE,
{"message": "test_message", "level": "debug"},
)
await hass.async_block_till_done()
assert logger.method_calls[0] == ("debug", ("test_message",))