mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Fix modem_callerid test warning (#57760)
This commit is contained in:
parent
0f2b5ea28e
commit
5aba8a7c81
@ -11,15 +11,16 @@ CONF_DATA = {CONF_DEVICE: DEFAULT_PORT}
|
|||||||
IMPORT_DATA = {"sensor": {"platform": "modem_callerid"}}
|
IMPORT_DATA = {"sensor": {"platform": "modem_callerid"}}
|
||||||
|
|
||||||
|
|
||||||
def _patch_init_modem(mocked_modem):
|
def _patch_init_modem():
|
||||||
return patch(
|
return patch(
|
||||||
"homeassistant.components.modem_callerid.PhoneModem",
|
"homeassistant.components.modem_callerid.PhoneModem",
|
||||||
return_value=mocked_modem,
|
autospec=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _patch_config_flow_modem(mocked_modem):
|
def _patch_config_flow_modem(mocked_modem):
|
||||||
return patch(
|
return patch(
|
||||||
"homeassistant.components.modem_callerid.config_flow.PhoneModem",
|
"homeassistant.components.modem_callerid.config_flow.PhoneModem",
|
||||||
|
autospec=True,
|
||||||
return_value=mocked_modem,
|
return_value=mocked_modem,
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Test Modem Caller ID integration."""
|
"""Test Modem Caller ID integration."""
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from phone_modem import exceptions
|
from phone_modem import exceptions
|
||||||
|
|
||||||
@ -19,8 +19,7 @@ async def test_setup_config(hass: HomeAssistant):
|
|||||||
data=CONF_DATA,
|
data=CONF_DATA,
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
mocked_modem = AsyncMock()
|
with _patch_init_modem():
|
||||||
with _patch_init_modem(mocked_modem):
|
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
assert entry.state == ConfigEntryState.LOADED
|
assert entry.state == ConfigEntryState.LOADED
|
||||||
|
|
||||||
@ -50,8 +49,7 @@ async def test_unload_config_entry(hass: HomeAssistant):
|
|||||||
data=CONF_DATA,
|
data=CONF_DATA,
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
mocked_modem = AsyncMock()
|
with _patch_init_modem():
|
||||||
with _patch_init_modem(mocked_modem):
|
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
assert entry.state is ConfigEntryState.LOADED
|
assert entry.state is ConfigEntryState.LOADED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user