mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Improve type hints in subaru tests (#123911)
This commit is contained in:
parent
99b1fc75d3
commit
2c99bd178c
@ -100,7 +100,7 @@ TEST_DEVICE_NAME = "test_vehicle_2"
|
|||||||
TEST_ENTITY_ID = f"sensor.{TEST_DEVICE_NAME}_odometer"
|
TEST_ENTITY_ID = f"sensor.{TEST_DEVICE_NAME}_odometer"
|
||||||
|
|
||||||
|
|
||||||
def advance_time_to_next_fetch(hass):
|
def advance_time_to_next_fetch(hass: HomeAssistant) -> None:
|
||||||
"""Fast forward time to next fetch."""
|
"""Fast forward time to next fetch."""
|
||||||
future = dt_util.utcnow() + timedelta(seconds=FETCH_INTERVAL + 30)
|
future = dt_util.utcnow() + timedelta(seconds=FETCH_INTERVAL + 30)
|
||||||
async_fire_time_changed(hass, future)
|
async_fire_time_changed(hass, future)
|
||||||
@ -181,7 +181,7 @@ async def setup_subaru_config_entry(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def subaru_config_entry(hass):
|
async def subaru_config_entry(hass: HomeAssistant) -> MockConfigEntry:
|
||||||
"""Create a Subaru config entry prior to setup."""
|
"""Create a Subaru config entry prior to setup."""
|
||||||
await async_setup_component(hass, HA_DOMAIN, {})
|
await async_setup_component(hass, HA_DOMAIN, {})
|
||||||
config_entry = MockConfigEntry(**TEST_CONFIG_ENTRY)
|
config_entry = MockConfigEntry(**TEST_CONFIG_ENTRY)
|
||||||
@ -190,7 +190,9 @@ async def subaru_config_entry(hass):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def ev_entry(hass, subaru_config_entry):
|
async def ev_entry(
|
||||||
|
hass: HomeAssistant, subaru_config_entry: MockConfigEntry
|
||||||
|
) -> MockConfigEntry:
|
||||||
"""Create a Subaru entry representing an EV vehicle with full STARLINK subscription."""
|
"""Create a Subaru entry representing an EV vehicle with full STARLINK subscription."""
|
||||||
await setup_subaru_config_entry(hass, subaru_config_entry)
|
await setup_subaru_config_entry(hass, subaru_config_entry)
|
||||||
assert DOMAIN in hass.config_entries.async_domains()
|
assert DOMAIN in hass.config_entries.async_domains()
|
||||||
|
@ -10,6 +10,7 @@ from subarulink.exceptions import InvalidCredentials, InvalidPIN, SubaruExceptio
|
|||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.subaru import config_flow
|
from homeassistant.components.subaru import config_flow
|
||||||
from homeassistant.components.subaru.const import CONF_UPDATE_ENABLED, DOMAIN
|
from homeassistant.components.subaru.const import CONF_UPDATE_ENABLED, DOMAIN
|
||||||
|
from homeassistant.config_entries import ConfigFlowResult
|
||||||
from homeassistant.const import CONF_DEVICE_ID, CONF_PIN
|
from homeassistant.const import CONF_DEVICE_ID, CONF_PIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -389,7 +390,7 @@ async def test_option_flow(hass: HomeAssistant, options_form) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def user_form(hass):
|
async def user_form(hass: HomeAssistant) -> ConfigFlowResult:
|
||||||
"""Return initial form for Subaru config flow."""
|
"""Return initial form for Subaru config flow."""
|
||||||
return await hass.config_entries.flow.async_init(
|
return await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
@ -397,7 +398,9 @@ async def user_form(hass):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def two_factor_start_form(hass, user_form):
|
async def two_factor_start_form(
|
||||||
|
hass: HomeAssistant, user_form: ConfigFlowResult
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Return two factor form for Subaru config flow."""
|
"""Return two factor form for Subaru config flow."""
|
||||||
with (
|
with (
|
||||||
patch(MOCK_API_CONNECT, return_value=True),
|
patch(MOCK_API_CONNECT, return_value=True),
|
||||||
@ -410,7 +413,9 @@ async def two_factor_start_form(hass, user_form):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def two_factor_verify_form(hass, two_factor_start_form):
|
async def two_factor_verify_form(
|
||||||
|
hass: HomeAssistant, two_factor_start_form: ConfigFlowResult
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Return two factor form for Subaru config flow."""
|
"""Return two factor form for Subaru config flow."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
@ -427,7 +432,9 @@ async def two_factor_verify_form(hass, two_factor_start_form):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def pin_form(hass, two_factor_verify_form):
|
async def pin_form(
|
||||||
|
hass: HomeAssistant, two_factor_verify_form: ConfigFlowResult
|
||||||
|
) -> ConfigFlowResult:
|
||||||
"""Return PIN input form for Subaru config flow."""
|
"""Return PIN input form for Subaru config flow."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
@ -443,7 +450,7 @@ async def pin_form(hass, two_factor_verify_form):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def options_form(hass):
|
async def options_form(hass: HomeAssistant) -> ConfigFlowResult:
|
||||||
"""Return options form for Subaru config flow."""
|
"""Return options form for Subaru config flow."""
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data={}, options=None)
|
entry = MockConfigEntry(domain=DOMAIN, data={}, options=None)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user