Cleanup log style and tests for ElkM1 (#42353)

This commit is contained in:
Glenn Waters 2020-10-26 05:36:28 -04:00 committed by GitHub
parent 8f74a0c2e6
commit 6645cb2637
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View file

@ -313,10 +313,10 @@ async def async_wait_for_elk_to_sync(elk, timeout, conf_host):
success = succeeded success = succeeded
if succeeded: if succeeded:
_LOGGER.info("ElkM1 login succeeded.") _LOGGER.debug("ElkM1 login succeeded")
else: else:
elk.disconnect() elk.disconnect()
_LOGGER.error("ElkM1 login failed; invalid username or password.") _LOGGER.error("ElkM1 login failed; invalid username or password")
event.set() event.set()
def sync_complete(): def sync_complete():
@ -332,7 +332,7 @@ async def async_wait_for_elk_to_sync(elk, timeout, conf_host):
except asyncio.TimeoutError: except asyncio.TimeoutError:
_LOGGER.error( _LOGGER.error(
"Timed out after %d seconds while trying to sync with ElkM1 at %s", "Timed out after %d seconds while trying to sync with ElkM1 at %s",
SYNC_TIMEOUT, timeout,
conf_host, conf_host,
) )
elk.disconnect() elk.disconnect()

View file

@ -163,8 +163,6 @@ async def test_form_user_with_serial_elk(hass):
async def test_form_cannot_connect(hass): async def test_form_cannot_connect(hass):
"""Test we handle cannot connect error.""" """Test we handle cannot connect error."""
from asyncio import TimeoutError
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
@ -175,8 +173,8 @@ async def test_form_cannot_connect(hass):
"homeassistant.components.elkm1.config_flow.elkm1.Elk", "homeassistant.components.elkm1.config_flow.elkm1.Elk",
return_value=mocked_elk, return_value=mocked_elk,
), patch( ), patch(
"homeassistant.components.elkm1.async_timeout.timeout", "homeassistant.components.elkm1.config_flow.VALIDATE_TIMEOUT",
side_effect=TimeoutError, 0,
): ):
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],