mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Make elevenlabs recoverable (#134094)
* Make elevenlabs recoverable * Add tests for entry setup * Use the same fixtures for setup and config flow * Update tests/components/elevenlabs/test_setup.py Co-authored-by: Simon <80467011+sorgfresser@users.noreply.github.com> --------- Co-authored-by: Simon Sorg <simon.sorg@student.hpi.de> Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Simon <80467011+sorgfresser@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
873b078bb3
commit
c23f5c9f2c
36
tests/components/elevenlabs/test_setup.py
Normal file
36
tests/components/elevenlabs/test_setup.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""Tests for the ElevenLabs TTS entity."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_setup(
|
||||
hass: HomeAssistant,
|
||||
mock_async_client: MagicMock,
|
||||
mock_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test entry setup without any exceptions."""
|
||||
mock_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||
assert mock_entry.state == ConfigEntryState.LOADED
|
||||
# Unload
|
||||
await hass.config_entries.async_unload(mock_entry.entry_id)
|
||||
assert mock_entry.state == ConfigEntryState.NOT_LOADED
|
||||
|
||||
|
||||
async def test_setup_connect_error(
|
||||
hass: HomeAssistant,
|
||||
mock_async_client_connect_error: MagicMock,
|
||||
mock_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test entry setup with a connection error."""
|
||||
mock_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||
# Ensure is not ready
|
||||
assert mock_entry.state == ConfigEntryState.SETUP_RETRY
|
||||
Reference in New Issue
Block a user