core/tests/components/energyzero/test_config_flow.py

36 lines
1.0 KiB
Python

"""Test the EnergyZero config flow."""
from unittest.mock import MagicMock
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.energyzero.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_full_user_flow(
hass: HomeAssistant,
mock_setup_entry: MagicMock,
snapshot: SnapshotAssertion,
) -> None:
"""Test the full user configuration flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
assert "flow_id" in result
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={},
)
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2 == snapshot
assert len(mock_setup_entry.mock_calls) == 1