tests
Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
This commit is contained in:
parent
a40eeefc8c
commit
182f8b33f7
2 changed files with 31 additions and 13 deletions
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.mill.const import CLOUD, CONNECTION_TYPE, DOMAIN, LOCAL
|
||||
from homeassistant.components.recorder import Recorder
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
@ -11,7 +12,7 @@ from homeassistant.data_entry_flow import FlowResultType
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_show_config_form(hass: HomeAssistant) -> None:
|
||||
async def test_show_config_form(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test show configuration form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -21,7 +22,7 @@ async def test_show_config_form(hass: HomeAssistant) -> None:
|
|||
assert result["step_id"] == "user"
|
||||
|
||||
|
||||
async def test_create_entry(hass: HomeAssistant) -> None:
|
||||
async def test_create_entry(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test create entry from user input."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -56,7 +57,9 @@ async def test_create_entry(hass: HomeAssistant) -> None:
|
|||
}
|
||||
|
||||
|
||||
async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
||||
async def test_flow_entry_already_exists(
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test user input for config_entry that already exists."""
|
||||
|
||||
test_data = {
|
||||
|
@ -96,7 +99,7 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_connection_error(hass: HomeAssistant) -> None:
|
||||
async def test_connection_error(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test connection error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -125,7 +128,7 @@ async def test_connection_error(hass: HomeAssistant) -> None:
|
|||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_local_create_entry(hass: HomeAssistant) -> None:
|
||||
async def test_local_create_entry(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test create entry from user input."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
|
@ -165,7 +168,9 @@ async def test_local_create_entry(hass: HomeAssistant) -> None:
|
|||
assert result["data"] == test_data
|
||||
|
||||
|
||||
async def test_local_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
||||
async def test_local_flow_entry_already_exists(
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test user input for config_entry that already exists."""
|
||||
|
||||
test_data = {
|
||||
|
@ -215,7 +220,9 @@ async def test_local_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
|||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_local_connection_error(hass: HomeAssistant) -> None:
|
||||
async def test_local_connection_error(
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test connection error."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
|
|
@ -4,6 +4,7 @@ import asyncio
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components import mill
|
||||
from homeassistant.components.recorder import Recorder
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -11,7 +12,9 @@ from homeassistant.setup import async_setup_component
|
|||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_setup_with_cloud_config(hass: HomeAssistant) -> None:
|
||||
async def test_setup_with_cloud_config(
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test setup of cloud config."""
|
||||
entry = MockConfigEntry(
|
||||
domain=mill.DOMAIN,
|
||||
|
@ -31,7 +34,9 @@ async def test_setup_with_cloud_config(hass: HomeAssistant) -> None:
|
|||
assert len(mock_connect.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_setup_with_cloud_config_fails(hass: HomeAssistant) -> None:
|
||||
async def test_setup_with_cloud_config_fails(
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test setup of cloud config."""
|
||||
entry = MockConfigEntry(
|
||||
domain=mill.DOMAIN,
|
||||
|
@ -47,7 +52,9 @@ async def test_setup_with_cloud_config_fails(hass: HomeAssistant) -> None:
|
|||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_setup_with_cloud_config_times_out(hass: HomeAssistant) -> None:
|
||||
async def test_setup_with_cloud_config_times_out(
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test setup of cloud config will retry if timed out."""
|
||||
entry = MockConfigEntry(
|
||||
domain=mill.DOMAIN,
|
||||
|
@ -63,7 +70,9 @@ async def test_setup_with_cloud_config_times_out(hass: HomeAssistant) -> None:
|
|||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_setup_with_old_cloud_config(hass: HomeAssistant) -> None:
|
||||
async def test_setup_with_old_cloud_config(
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test setup of old cloud config."""
|
||||
entry = MockConfigEntry(
|
||||
domain=mill.DOMAIN,
|
||||
|
@ -82,7 +91,9 @@ async def test_setup_with_old_cloud_config(hass: HomeAssistant) -> None:
|
|||
assert len(mock_connect.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_setup_with_local_config(hass: HomeAssistant) -> None:
|
||||
async def test_setup_with_local_config(
|
||||
recorder_mock: Recorder, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test setup of local config."""
|
||||
entry = MockConfigEntry(
|
||||
domain=mill.DOMAIN,
|
||||
|
@ -119,7 +130,7 @@ async def test_setup_with_local_config(hass: HomeAssistant) -> None:
|
|||
assert len(mock_connect.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_unload_entry(hass: HomeAssistant) -> None:
|
||||
async def test_unload_entry(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test removing mill client."""
|
||||
entry = MockConfigEntry(
|
||||
domain=mill.DOMAIN,
|
||||
|
|
Loading…
Add table
Reference in a new issue