Fix unhandled exceptions for config, default_config, harmony (#33731)

* replaced MagicMock with CoroutineMock to avoid exception

* added conversion to str so mock returns unique-id that doesn't throw json exception

* added non-empty config since hass throws exception when config is empty
This commit is contained in:
Ziv 2020-04-06 14:36:49 +03:00 committed by Paulus Schoutsen
parent d92d74a14f
commit 4901fa24ec
4 changed files with 6 additions and 6 deletions

View File

@ -11,7 +11,7 @@ def find_unique_id_for_remote(harmony: HarmonyAPI):
"""Find the unique id for both websocket and xmpp clients."""
websocket_unique_id = harmony.hub_config.info.get("activeRemoteId")
if websocket_unique_id is not None:
return websocket_unique_id
return str(websocket_unique_id)
# fallback to the xmpp unique id if websocket is not available
return harmony.config["global"]["timeStampHash"].split(";")[-1]

View File

@ -1,6 +1,8 @@
"""Test Group config panel."""
import json
from unittest.mock import MagicMock, patch
from unittest.mock import patch
from asynctest import CoroutineMock
from homeassistant.bootstrap import async_setup_component
from homeassistant.components import config
@ -50,7 +52,7 @@ async def test_update_device_config(hass, hass_client):
"""Mock writing data."""
written.append(data)
mock_call = MagicMock()
mock_call = CoroutineMock()
with patch("homeassistant.components.config._read", mock_read), patch(
"homeassistant.components.config._write", mock_write

View File

@ -34,4 +34,4 @@ def recorder_url_mock():
async def test_setup(hass):
"""Test setup."""
assert await async_setup_component(hass, "default_config", {})
assert await async_setup_component(hass, "default_config", {"foo": "bar"})

View File

@ -4,8 +4,6 @@ IGNORE_UNCAUGHT_EXCEPTIONS = [
("tests.components.cast.test_media_player", "test_entry_setup_single_config"),
("tests.components.cast.test_media_player", "test_entry_setup_list_config"),
("tests.components.cast.test_media_player", "test_entry_setup_platform_not_ready"),
("tests.components.config.test_group", "test_update_device_config"),
("tests.components.default_config.test_init", "test_setup"),
("tests.components.demo.test_init", "test_setting_up_demo"),
("tests.components.discovery.test_init", "test_discover_config_flow"),
("tests.components.dsmr.test_sensor", "test_default_setup"),