async def test_options_flow(hass, aioclient_mock: AiohttpClientMocker): """Test updating options.""" entry = await setup_integration(hass, aioclient_mock, skip_entry_setup=True) assert entry.options[CONF_UPCOMING_DAYS] == DEFAULT_UPCOMING_DAYS assert entry.options[CONF_WANTED_MAX_ITEMS] == DEFAULT_WANTED_MAX_ITEMS result = await hass.config_entries.options.async_init(entry.entry_id) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "init" with _patch_async_setup(), _patch_async_setup_entry(): result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={ CONF_UPCOMING_DAYS: 2, CONF_WANTED_MAX_ITEMS: 100 }, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY assert result["data"][CONF_UPCOMING_DAYS] == 2 assert result["data"][CONF_WANTED_MAX_ITEMS] == 100
async def test_full_user_flow_advanced_options( hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker) -> None: """Test the full manual user flow with advanced options.""" mock_connection(aioclient_mock) result = await hass.config_entries.flow.async_init( DOMAIN, context={ CONF_SOURCE: SOURCE_USER, "show_advanced_options": True }) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "user" user_input = { **MOCK_USER_INPUT, CONF_VERIFY_SSL: True, } with _patch_async_setup(), _patch_async_setup_entry(): result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=user_input, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY assert result["title"] == HOST assert result["data"] assert result["data"][CONF_HOST] == HOST assert result["data"][CONF_VERIFY_SSL]
async def test_full_user_flow_implementation( hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker) -> None: """Test the full manual user flow from start to finish.""" mock_connection(aioclient_mock) result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_USER}, ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "user" user_input = MOCK_USER_INPUT.copy() with _patch_async_setup(), _patch_async_setup_entry(): result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=user_input, ) assert result["type"] == RESULT_TYPE_CREATE_ENTRY assert result["title"] == HOST assert result["data"] assert result["data"][CONF_HOST] == HOST
async def test_options_flow(hass, aioclient_mock: AiohttpClientMocker): """Test updating options.""" with patch("homeassistant.components.sonarr.PLATFORMS", []): entry = await setup_integration(hass, aioclient_mock) assert entry.options[CONF_UPCOMING_DAYS] == DEFAULT_UPCOMING_DAYS assert entry.options[CONF_WANTED_MAX_ITEMS] == DEFAULT_WANTED_MAX_ITEMS result = await hass.config_entries.options.async_init(entry.entry_id) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "init" with _patch_async_setup(), _patch_async_setup_entry(): result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={ CONF_UPCOMING_DAYS: 2, CONF_WANTED_MAX_ITEMS: 100 }, ) await hass.async_block_till_done() assert result["type"] == RESULT_TYPE_CREATE_ENTRY assert result["data"][CONF_UPCOMING_DAYS] == 2 assert result["data"][CONF_WANTED_MAX_ITEMS] == 100
async def test_import_from_sensor_component( hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker) -> None: """Test import from sensor platform.""" mock_connection(aioclient_mock) with _patch_async_setup(), _patch_async_setup_entry(): assert await async_setup_component(hass, SENSOR_DOMAIN, {SENSOR_DOMAIN: MOCK_SENSOR_CONFIG}) await hass.async_block_till_done() entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1 assert entries[0].state == ENTRY_STATE_LOADED assert entries[0].data[CONF_BASE_PATH] == "/api"
async def test_full_reauth_flow_implementation( hass: HomeAssistantType, aioclient_mock: AiohttpClientMocker) -> None: """Test the manual reauth flow from start to finish.""" entry = await setup_integration(hass, aioclient_mock, skip_entry_setup=True) assert entry result = await hass.config_entries.flow.async_init( DOMAIN, context={CONF_SOURCE: SOURCE_REAUTH}, data={ "config_entry_id": entry.entry_id, **entry.data }, ) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "reauth_confirm" result = await hass.config_entries.flow.async_configure(result["flow_id"], user_input={}) assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "user" user_input = MOCK_REAUTH_INPUT.copy() with _patch_async_setup(), _patch_async_setup_entry() as mock_setup_entry: result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=user_input) await hass.async_block_till_done() assert result["type"] == RESULT_TYPE_ABORT assert result["reason"] == "reauth_successful" assert entry.data[CONF_API_KEY] == "test-api-key-reauth" mock_setup_entry.assert_called_once()