1
0
mirror of https://github.com/home-assistant/core.git synced 2026-03-05 00:58:47 +00:00
Files
core/tests/components/default_config/test_init.py
Ziv 4901fa24ec 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
2020-04-07 10:29:15 -07:00

38 lines
905 B
Python

"""Test the default_config init."""
from unittest.mock import patch
import pytest
from homeassistant.setup import async_setup_component
from tests.common import MockDependency, mock_coro
@pytest.fixture(autouse=True)
def zeroconf_mock():
"""Mock zeroconf."""
with MockDependency("zeroconf") as mocked_zeroconf:
mocked_zeroconf.Zeroconf.return_value.register_service.return_value = mock_coro(
True
)
yield
@pytest.fixture(autouse=True)
def netdisco_mock():
"""Mock netdisco."""
with MockDependency("netdisco", "discovery"):
yield
@pytest.fixture(autouse=True)
def recorder_url_mock():
"""Mock recorder url."""
with patch("homeassistant.components.recorder.DEFAULT_URL", "sqlite://"):
yield
async def test_setup(hass):
"""Test setup."""
assert await async_setup_component(hass, "default_config", {"foo": "bar"})