mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Set up the config entry directly in Mill tests (#195366)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
b83c61f371
commit
02e9bd5d60
@@ -6,12 +6,10 @@ from unittest.mock import patch
|
||||
from pytest_homeassistant.common import MockConfigEntry
|
||||
|
||||
from homeassistant.components import mill
|
||||
from homeassistant.components.mill import DOMAIN
|
||||
from homeassistant.components.mill.coordinator import MillDataUpdateCoordinator
|
||||
from homeassistant.components.recorder import Recorder
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
async def test_setup_with_cloud_config(
|
||||
@@ -31,7 +29,7 @@ async def test_setup_with_cloud_config(
|
||||
patch("mill.Mill.fetch_heater_and_sensor_data", return_value={}) as mock_fetch,
|
||||
patch("mill.Mill.connect", return_value=True) as mock_connect,
|
||||
):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
assert len(mock_fetch.mock_calls) == 1
|
||||
assert len(mock_connect.mock_calls) == 1
|
||||
|
||||
@@ -50,7 +48,7 @@ async def test_setup_with_cloud_config_fails(
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
with patch("mill.Mill.connect", return_value=False):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
@@ -88,7 +86,7 @@ async def test_setup_with_old_cloud_config(
|
||||
patch("mill.Mill.fetch_heater_and_sensor_data", return_value={}),
|
||||
patch("mill.Mill.connect", return_value=True) as mock_connect,
|
||||
):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
|
||||
assert len(mock_connect.mock_calls) == 1
|
||||
|
||||
@@ -126,7 +124,7 @@ async def test_setup_with_local_config(
|
||||
},
|
||||
) as mock_connect,
|
||||
):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
|
||||
assert len(mock_fetch.mock_calls) == 1
|
||||
assert len(mock_connect.mock_calls) == 1
|
||||
@@ -156,7 +154,7 @@ async def test_unload_entry(recorder_mock: Recorder, hass: HomeAssistant) -> Non
|
||||
return_value=True,
|
||||
),
|
||||
):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
|
||||
assert isinstance(entry.runtime_data, MillDataUpdateCoordinator)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user