|
|
@@ -1,7 +1,7 @@
|
|
|
"""Tests for the lock entity."""
|
|
|
import pytest
|
|
|
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
|
|
-from unittest.mock import AsyncMock
|
|
|
+from unittest.mock import AsyncMock, Mock
|
|
|
|
|
|
from custom_components.tuya_local.const import (
|
|
|
CONF_CHILD_LOCK,
|
|
|
@@ -15,13 +15,16 @@ from custom_components.tuya_local.heater.lock import GoldairHeaterChildLock
|
|
|
from custom_components.tuya_local.lock import async_setup_entry
|
|
|
|
|
|
|
|
|
-@pytest.mark.asyncio
|
|
|
async def test_init_entry(hass):
|
|
|
"""Test the initialisation."""
|
|
|
entry = MockConfigEntry(
|
|
|
- domain=DOMAIN, data={CONF_TYPE: CONF_TYPE_AUTO, CONF_DEVICE_ID: "dummy"},
|
|
|
+ domain=DOMAIN,
|
|
|
+ data={CONF_TYPE: CONF_TYPE_AUTO, CONF_DEVICE_ID: "dummy"},
|
|
|
)
|
|
|
- m_add_entities = AsyncMock()
|
|
|
+ # although async, the async_add_entities function passed to
|
|
|
+ # async_setup_entry is called truly asynchronously. If we use
|
|
|
+ # AsyncMock, it expects us to await the result.
|
|
|
+ m_add_entities = Mock()
|
|
|
m_device = AsyncMock()
|
|
|
m_device.async_inferred_type = AsyncMock(return_value=CONF_TYPE_GPPH_HEATER)
|
|
|
|