Beispiel #1
0
async def test_full_flow_implementation(
        hass,
        mock_logi_circle  # pylint: disable=redefined-outer-name
):
    """Test registering an implementation and finishing flow works."""
    config_flow.register_flow_implementation(
        hass,
        "test-other",
        client_id=None,
        client_secret=None,
        api_key=None,
        redirect_uri=None,
        sensors=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-other"})
    assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
    assert result["step_id"] == "auth"
    assert result["description_placeholders"] == {
        "authorization_url": "http://example.com"
    }

    result = await flow.async_step_code("123ABC")
    assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
    assert result["title"] == "Logi Circle ({})".format("testId")
Beispiel #2
0
async def test_full_flow_implementation(hass, mock_logi_circle):  # noqa pylint: disable=W0621
    """Test registering an implementation and finishing flow works."""
    config_flow.register_flow_implementation(hass,
                                             'test-other',
                                             client_id=None,
                                             client_secret=None,
                                             api_key=None,
                                             redirect_uri=None,
                                             sensors=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-other'})
    assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
    assert result['step_id'] == 'auth'
    assert result['description_placeholders'] == {
        'authorization_url': 'http://example.com',
    }

    result = await flow.async_step_code('123ABC')
    assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
    assert result['title'] == 'Logi Circle ({})'.format('testId')
Beispiel #3
0
def init_config_flow(hass):
    """Init a configuration flow."""
    config_flow.register_flow_implementation(hass,
                                             DOMAIN,
                                             client_id='id',
                                             client_secret='secret',
                                             api_key='123',
                                             redirect_uri='http://example.com',
                                             sensors=None)
    flow = config_flow.LogiCircleFlowHandler()
    flow._get_authorization_url = Mock(  # pylint: disable=W0212
        return_value='http://example.com')
    flow.hass = hass
    return flow
Beispiel #4
0
def init_config_flow(hass):
    """Init a configuration flow."""
    config_flow.register_flow_implementation(
        hass,
        DOMAIN,
        client_id="id",
        client_secret="secret",
        api_key="123",
        redirect_uri="http://example.com",
        sensors=None,
    )
    flow = config_flow.LogiCircleFlowHandler()
    flow._get_authorization_url = Mock(  # pylint: disable=protected-access
        return_value="http://example.com")
    flow.hass = hass
    return flow
Beispiel #5
0
async def test_gen_auth_url(hass, mock_logi_circle):  # pylint: disable=W0621
    """Test generating authorize URL from Logi Circle API."""
    config_flow.register_flow_implementation(hass,
                                             'test-auth-url',
                                             client_id='id',
                                             client_secret='secret',
                                             api_key='123',
                                             redirect_uri='http://example.com',
                                             sensors=None)
    flow = config_flow.LogiCircleFlowHandler()
    flow.hass = hass
    flow.flow_impl = 'test-auth-url'
    await async_setup_component(hass, 'http', {})

    result = flow._get_authorization_url()  # pylint: disable=W0212
    assert result == 'http://authorize.url'
Beispiel #6
0
async def test_gen_auth_url(hass, mock_logi_circle):  # pylint: disable=redefined-outer-name
    """Test generating authorize URL from Logi Circle API."""
    config_flow.register_flow_implementation(
        hass,
        "test-auth-url",
        client_id="id",
        client_secret="secret",
        api_key="123",
        redirect_uri="http://example.com",
        sensors=None,
    )
    flow = config_flow.LogiCircleFlowHandler()
    flow.hass = hass
    flow.flow_impl = "test-auth-url"
    await async_setup_component(hass, "http", {})

    result = flow._get_authorization_url()  # pylint: disable=protected-access
    assert result == "http://authorize.url"