How to use the pydeconz.utils function in pydeconz

To help you get started, we’ve selected a few pydeconz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / home-assistant / tests / components / deconz / test_config_flow.py View on Github external
async def test_flow_works(hass, aioclient_mock):
    """Test that config flow works."""
    aioclient_mock.get(
        pydeconz.utils.URL_DISCOVER,
        json=[{"id": "id", "internalipaddress": "1.2.3.4", "internalport": 80}],
        headers={"content-type": "application/json"},
    )
    aioclient_mock.post(
        "http://1.2.3.4:80/api",
        json=[{"success": {"username": "1234567890ABCDEF"}}],
        headers={"content-type": "application/json"},
    )

    result = await hass.config_entries.flow.async_init(
        config_flow.DOMAIN, context={"source": "user"}
    )

    assert result["type"] == "form"
    assert result["step_id"] == "link"
github home-assistant / home-assistant / tests / components / deconz / test_config_flow.py View on Github external
async def test_user_step_manual_configuration_no_bridges_discovered(
    hass, aioclient_mock
):
    """Test config flow with manual input."""
    aioclient_mock.get(
        pydeconz.utils.URL_DISCOVER,
        json=[],
        headers={"content-type": "application/json"},
    )

    result = await hass.config_entries.flow.async_init(
        config_flow.DOMAIN, context={"source": "user"}
    )

    assert result["type"] == "form"
    assert result["step_id"] == "init"
    assert not hass.config_entries.flow._progress[result["flow_id"]].bridges

    result = await hass.config_entries.flow.async_configure(
        result["flow_id"],
        user_input={config_flow.CONF_HOST: "1.2.3.4", config_flow.CONF_PORT: 80},
    )
github Kane610 / deconz / tests / test_utils.py View on Github external
async def test_get_api_key() -> None:
    """Test a successful call of get_api_key."""
    session = Mock()

    with patch(
        "pydeconz.utils.async_request",
        new=CoroutineMock(return_value=[{"success": {"username": API_KEY}}]),
    ):
        response = await utils.async_get_api_key(session, IP, PORT)

    assert response == API_KEY
github Kane610 / deconz / tests / test_utils.py View on Github external
new=CoroutineMock(
            return_value=[
                {
                    "id": "123456FFFFABCDEF",
                    "internalipaddress": "host1",
                    "internalport": "port1",
                },
                {
                    "id": "234567BCDEFG",
                    "internalipaddress": "host2",
                    "internalport": "port2",
                },
            ]
        ),
    ):
        response = await utils.async_discovery(session)

    assert [
        {"bridgeid": "123456ABCDEF", "host": "host1", "port": "port1"},
        {"bridgeid": "234567BCDEFG", "host": "host2", "port": "port2"},
    ] == response