예제 #1
0
async def test_show_form(opp):
    """Test that the form is served with no input."""
    flow = config_flow.AmbientStationFlowHandler()
    flow.opp = opp
    flow.context = {"source": SOURCE_USER}

    result = await flow.async_step_user(user_input=None)

    assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
    assert result["step_id"] == "user"
예제 #2
0
async def test_no_devices(opp, mock_aioambient):
    """Test that an account with no associated devices throws an error."""
    conf = {
        CONF_API_KEY: "12345abcde12345abcde",
        CONF_APP_KEY: "67890fghij67890fghij"
    }

    flow = config_flow.AmbientStationFlowHandler()
    flow.opp = opp
    flow.context = {"source": SOURCE_USER}

    result = await flow.async_step_user(user_input=conf)
    assert result["errors"] == {"base": "no_devices"}
예제 #3
0
async def test_invalid_api_key(opp, mock_aioambient):
    """Test that an invalid API/App Key throws an error."""
    conf = {
        CONF_API_KEY: "12345abcde12345abcde",
        CONF_APP_KEY: "67890fghij67890fghij"
    }

    flow = config_flow.AmbientStationFlowHandler()
    flow.opp = opp
    flow.context = {"source": SOURCE_USER}

    result = await flow.async_step_user(user_input=conf)
    assert result["errors"] == {"base": "invalid_key"}
예제 #4
0
async def test_step_import(opp, mock_aioambient):
    """Test that the import step works."""
    conf = {
        CONF_API_KEY: "12345abcde12345abcde",
        CONF_APP_KEY: "67890fghij67890fghij"
    }

    flow = config_flow.AmbientStationFlowHandler()
    flow.opp = opp
    flow.context = {"source": SOURCE_USER}

    result = await flow.async_step_import(import_config=conf)
    assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
    assert result["title"] == "67890fghij67"
    assert result["data"] == {
        CONF_API_KEY: "12345abcde12345abcde",
        CONF_APP_KEY: "67890fghij67890fghij",
    }