Support vizio pairing through config flow (#31520)
* support pairing through config flow * simplify import failure log messages * remove unnecessary list comprehension * bump pyvizio to add passing ClientSession in where it was missed * show different message if user completes pairing through import * remove dupe failure message since reasons for failure are the same in both instances * remove extra constant * add host reachability check during pairing workflow * revert redundant connection check since check is implicitly done during pairing process * fix rebase errors * fix string * updates based on review * update docstring * missed commit * update import confirmation message to be less wordy * use ConfigFlow _abort_if_unique_id_configured * fix test
This commit is contained in:
1 parent
03d8abe1ba
commit
b9fa32444a
6 files changed
+388
-67
No files matched your search
@@ -3,7 +3,18 @@ from asynctest import patch
|
||||
import pytest
|
||||
from pyvizio.const import DEVICE_CLASS_SPEAKER, MAX_VOLUME
|
||||
|
||||
from .const import CURRENT_INPUT, INPUT_LIST, MODEL, UNIQUE_ID, VERSION
|
||||
from .const import (
|
||||
ACCESS_TOKEN,
|
||||
CH_TYPE,
|
||||
CURRENT_INPUT,
|
||||
INPUT_LIST,
|
||||
MODEL,
|
||||
RESPONSE_TOKEN,
|
||||
UNIQUE_ID,
|
||||
VERSION,
|
||||
MockCompletePairingResponse,
|
||||
MockStartPairingResponse,
|
||||
)
|
||||
|
||||
|
||||
class MockInput:
|
||||
@@ -42,6 +53,41 @@ def vizio_connect_fixture():
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="vizio_complete_pairing")
|
||||
def vizio_complete_pairing_fixture():
|
||||
"""Mock complete vizio pairing workflow."""
|
||||
with patch(
|
||||
"homeassistant.components.vizio.config_flow.VizioAsync.start_pair",
|
||||
return_value=MockStartPairingResponse(CH_TYPE, RESPONSE_TOKEN),
|
||||
), patch(
|
||||
"homeassistant.components.vizio.config_flow.VizioAsync.pair",
|
||||
return_value=MockCompletePairingResponse(ACCESS_TOKEN),
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="vizio_start_pairing_failure")
|
||||
def vizio_start_pairing_failure_fixture():
|
||||
"""Mock vizio start pairing failure."""
|
||||
with patch(
|
||||
"homeassistant.components.vizio.config_flow.VizioAsync.start_pair",
|
||||
return_value=None,
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="vizio_invalid_pin_failure")
|
||||
def vizio_invalid_pin_failure_fixture():
|
||||
"""Mock vizio failure due to invalid pin."""
|
||||
with patch(
|
||||
"homeassistant.components.vizio.config_flow.VizioAsync.start_pair",
|
||||
return_value=MockStartPairingResponse(CH_TYPE, RESPONSE_TOKEN),
|
||||
), patch(
|
||||
"homeassistant.components.vizio.config_flow.VizioAsync.pair", return_value=None,
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="vizio_bypass_setup")
|
||||
def vizio_bypass_setup_fixture():
|
||||
"""Mock component setup."""
|
||||
|
||||
Reference in new issue
Block a user