mirror of
https://github.com/home-assistant/core.git
synced 2026-04-27 12:14:35 +01:00
Add config entry to go2rtc (#129436)
* Add config entry to go2rtc * Address review comments * Remove config entry if go2rtc is not configured * Allow importing default_config * Address review comment
This commit is contained in:
45
tests/components/go2rtc/test_config_flow.py
Normal file
45
tests/components/go2rtc/test_config_flow.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""Test the Home Assistant Cloud config flow."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.go2rtc.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_config_flow(hass: HomeAssistant) -> None:
|
||||
"""Test create cloud entry."""
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.go2rtc.async_setup", return_value=True
|
||||
) as mock_setup,
|
||||
patch(
|
||||
"homeassistant.components.go2rtc.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": "system"}
|
||||
)
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "go2rtc"
|
||||
assert result["data"] == {}
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_multiple_entries(hass: HomeAssistant) -> None:
|
||||
"""Test creating multiple cloud entries."""
|
||||
config_entry = MockConfigEntry(domain=DOMAIN)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": "system"}
|
||||
)
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
Reference in New Issue
Block a user