Esempio n. 1
0
async def test_secure_device_pin_config(hass):
    """Test the setting of the secure device pin configuration."""
    secure_pin = "TEST"
    secure_config = GOOGLE_ASSISTANT_SCHEMA({
        "project_id": "1234",
        "service_account": {
            "private_key":
            "-----BEGIN PRIVATE KEY-----\nMIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKYscIlwm7soDsHAz6L6YvUkCvkrX19rS6yeYOmovvhoK5WeYGWUsd8V72zmsyHB7XO94YgJVjvxfzn5K8bLePjFzwoSJjZvhBJ/ZQ05d8VmbvgyWUoPdG9oEa4fZ/lCYrXoaFdTot2xcJvrb/ZuiRl4s4eZpNeFYvVK/Am7UeFPAgMBAAECgYAUetOfzLYUudofvPCaKHu7tKZ5kQPfEa0w6BAPnBF1Mfl1JiDBRDMryFtKs6AOIAVwx00dY/Ex0BCbB3+Cr58H7t4NaPTJxCpmR09pK7o17B7xAdQv8+SynFNud9/5vQ5AEXMOLNwKiU7wpXT6Z7ZIibUBOR7ewsWgsHCDpN1iqQJBAOMODPTPSiQMwRAUHIc6GPleFSJnIz2PAoG3JOG9KFAL6RtIc19lob2ZXdbQdzKtjSkWo+O5W20WDNAl1k32h6MCQQC7W4ZCIY67mPbL6CxXfHjpSGF4Dr9VWJ7ZrKHr6XUoOIcEvsn/pHvWonjMdy93rQMSfOE8BKd/I1+GHRmNVgplAkAnSo4paxmsZVyfeKt7Jy2dMY+8tVZe17maUuQaAE7Sk00SgJYegwrbMYgQnWCTL39HBfj0dmYA2Zj8CCAuu6O7AkEAryFiYjaUAO9+4iNoL27+ZrFtypeeadyov7gKs0ZKaQpNyzW8A+Zwi7TbTeSqzic/E+z/bOa82q7p/6b7141xsQJBANCAcIwMcVb6KVCHlQbOtKspo5Eh4ZQi8bGl+IcwbQ6JSxeTx915IfAldgbuU047wOB04dYCFB2yLDiUGVXTifU=\n-----END PRIVATE KEY-----\n",
            "client_email": "*****@*****.**",
        },
        "secure_devices_pin": secure_pin,
    })
    config = GoogleConfig(hass, secure_config)

    assert config.secure_devices_pin == secure_pin
Esempio n. 2
0
async def test_call_homegraph_api_key_fail(hass, aioclient_mock, hass_storage):
    """Test the function to call the homegraph api."""
    config = GoogleConfig(
        hass,
        GOOGLE_ASSISTANT_SCHEMA({
            "project_id": "1234",
            "api_key": "dummy_key"
        }),
    )
    await config.async_initialize()

    aioclient_mock.post(MOCK_URL, status=666, json={})

    res = await config.async_call_homegraph_api_key(MOCK_URL, MOCK_JSON)
    assert res == 666
    assert aioclient_mock.call_count == 1
Esempio n. 3
0
async def test_missing_service_account(hass):
    """Test the google config _async_request_sync_devices."""
    incorrect_config = GOOGLE_ASSISTANT_SCHEMA({
        "project_id": "1234",
    })
    config = GoogleConfig(hass, incorrect_config)
    await config.async_initialize()

    with patch.object(config, "async_call_homegraph_api"):
        # Wait for google_assistant.helpers.async_initialize.sync_google to be called
        await hass.async_block_till_done()

    assert (await config._async_request_sync_devices("mock") is
            HTTPStatus.INTERNAL_SERVER_ERROR)
    renew = config._access_token_renew
    await config._async_update_token()
    assert config._access_token_renew is renew