* Add config flow to eight_sleep * simplify tests * Remove extra file * remove unused import * fix redundant code * Update homeassistant/components/eight_sleep/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * incorporate feedback * Review comments * remove typing from tests * Fix based on changes * Fix requirements * Remove stale comment * Fix tests * Reverse the flow and force the config entry to reconnect * Review comments * Abort if import flow fails * Split import and user logic * Fix error Co-authored-by: J. Nick Koston <nick@koston.org>
29 lines
868 B
Python
29 lines
868 B
Python
"""Fixtures for Eight Sleep."""
|
|
from unittest.mock import patch
|
|
|
|
from pyeight.exceptions import RequestError
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture(name="bypass", autouse=True)
|
|
def bypass_fixture():
|
|
"""Bypasses things that slow te tests down or block them from testing the behavior."""
|
|
with patch(
|
|
"homeassistant.components.eight_sleep.config_flow.EightSleep.fetch_token",
|
|
), patch(
|
|
"homeassistant.components.eight_sleep.config_flow.EightSleep.at_exit",
|
|
), patch(
|
|
"homeassistant.components.eight_sleep.async_setup_entry",
|
|
return_value=True,
|
|
):
|
|
yield
|
|
|
|
|
|
@pytest.fixture(name="token_error")
|
|
def token_error_fixture():
|
|
"""Simulate error when fetching token."""
|
|
with patch(
|
|
"homeassistant.components.eight_sleep.config_flow.EightSleep.fetch_token",
|
|
side_effect=RequestError,
|
|
):
|
|
yield
|