Exemple #1
0
async def test_auth_auth_check_and_register_with_exception(hass):
    """Test auth client registration."""
    config = {HMIPC_HAPID: "ABC123", HMIPC_PIN: "123", HMIPC_NAME: "hmip"}
    hmip_auth = HomematicipAuth(hass, config)
    hmip_auth.auth = Mock(spec=AsyncAuth)
    with patch.object(
        hmip_auth.auth, "isRequestAcknowledged", side_effect=HmipConnectionError
    ), patch.object(
        hmip_auth.auth, "requestAuthToken", side_effect=HmipConnectionError
    ):
        assert not await hmip_auth.async_checkbutton()
        assert await hmip_auth.async_register() is False
Exemple #2
0
async def test_auth_auth_check_and_register(hass):
    """Test auth client registration."""
    config = {HMIPC_HAPID: "ABC123", HMIPC_PIN: "123", HMIPC_NAME: "hmip"}

    hmip_auth = HomematicipAuth(hass, config)
    hmip_auth.auth = Mock(spec=AsyncAuth)
    with patch.object(hmip_auth.auth,
                      "isRequestAcknowledged",
                      return_value=True), patch.object(
                          hmip_auth.auth,
                          "requestAuthToken",
                          return_value="ABC"), patch.object(
                              hmip_auth.auth, "confirmAuthToken"):
        assert await hmip_auth.async_checkbutton()
        assert await hmip_auth.async_register() == "ABC"