Add reauth flow to webOS TV integration (#86168)
* Add reauth flow to webOS TV integration * Remove unnecessary else
This commit is contained in:
parent
f2b348dbdf
commit
c40c37e9ee
8 changed files with 217 additions and 37 deletions
39
tests/components/webostv/test_init.py
Normal file
39
tests/components/webostv/test_init.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
"""The tests for the LG webOS TV platform."""
|
||||
from unittest.mock import Mock
|
||||
|
||||
from aiowebostv import WebOsTvPairError
|
||||
|
||||
from homeassistant.components.webostv.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||
from homeassistant.const import CONF_CLIENT_SECRET
|
||||
|
||||
from . import setup_webostv
|
||||
|
||||
|
||||
async def test_reauth_setup_entry(hass, client, monkeypatch):
|
||||
"""Test reauth flow triggered by setup entry."""
|
||||
monkeypatch.setattr(client, "is_connected", Mock(return_value=False))
|
||||
monkeypatch.setattr(client, "connect", Mock(side_effect=WebOsTvPairError))
|
||||
entry = await setup_webostv(hass)
|
||||
|
||||
assert entry.state == ConfigEntryState.SETUP_ERROR
|
||||
|
||||
flows = hass.config_entries.flow.async_progress()
|
||||
assert len(flows) == 1
|
||||
|
||||
flow = flows[0]
|
||||
assert flow.get("step_id") == "reauth_confirm"
|
||||
assert flow.get("handler") == DOMAIN
|
||||
|
||||
assert "context" in flow
|
||||
assert flow["context"].get("source") == SOURCE_REAUTH
|
||||
assert flow["context"].get("entry_id") == entry.entry_id
|
||||
|
||||
|
||||
async def test_key_update_setup_entry(hass, client, monkeypatch):
|
||||
"""Test key update from setup entry."""
|
||||
monkeypatch.setattr(client, "client_key", "new_key")
|
||||
entry = await setup_webostv(hass)
|
||||
|
||||
assert entry.state == ConfigEntryState.LOADED
|
||||
assert entry.data[CONF_CLIENT_SECRET] == "new_key"
|
Loading…
Add table
Add a link
Reference in a new issue