Esempio n. 1
0
def init_config_flow(hass, side_effect=None):
    """Init a configuration flow."""
    config_flow.register_flow_implementation(hass, DOMAIN, 'id', 'secret')
    flow = config_flow.PointFlowHandler()
    flow._get_authorization_url = Mock(  # pylint: disable=W0212
        return_value=mock_coro('https://example.com'),
        side_effect=side_effect)
    flow.hass = hass
    return flow
Esempio n. 2
0
def init_config_flow(hass, side_effect=None):
    """Init a configuration flow."""
    config_flow.register_flow_implementation(hass, DOMAIN, "id", "secret")
    flow = config_flow.PointFlowHandler()
    flow._get_authorization_url = Mock(  # pylint: disable=protected-access
        return_value=mock_coro("https://example.com"),
        side_effect=side_effect)
    flow.hass = hass
    return flow
Esempio n. 3
0
async def test_full_flow_implementation(hass, mock_pypoint):  # noqa pylint: disable=W0621
    """Test registering an implementation and finishing flow works."""
    config_flow.register_flow_implementation(hass, 'test-other', None, None)
    flow = init_config_flow(hass)

    result = await flow.async_step_user()
    assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
    assert result['step_id'] == 'user'

    result = await flow.async_step_user({'flow_impl': 'test'})
    assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
    assert result['step_id'] == 'auth'
    assert result['description_placeholders'] == {
        'authorization_url': 'https://example.com',
    }

    result = await flow.async_step_code('123ABC')
    assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
    assert result['data']['refresh_args'] == {
        'client_id': 'id',
        'client_secret': 'secret'
    }
    assert result['title'] == '*****@*****.**'
    assert result['data']['token'] == {'access_token': 'boo'}