Fix Google Mail Sensor key error (#92262)

Fix Google Mail key error
This commit is contained in:
Robert Hillis 2023-04-29 20:20:43 -04:00 committed by GitHub
parent 895c0be82c
commit a5044227a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 6 deletions

View file

@ -0,0 +1,6 @@
{
"enableAutoReply": true,
"responseSubject": "Vacation",
"responseBodyPlainText": "I am on vacation.",
"restrictToContacts": false
}

View file

@ -4,6 +4,7 @@ from unittest.mock import patch
from google.auth.exceptions import RefreshError
from httplib2 import Response
import pytest
from homeassistant import config_entries
from homeassistant.components.google_mail.const import DOMAIN
@ -17,7 +18,17 @@ from .conftest import SENSOR, TOKEN, ComponentSetup
from tests.common import async_fire_time_changed, load_fixture
async def test_sensors(hass: HomeAssistant, setup_integration: ComponentSetup) -> None:
@pytest.mark.parametrize(
("fixture", "result"),
[
("get_vacation", "2022-11-18T05:00:00+00:00"),
("get_vacation_no_dates", STATE_UNKNOWN),
("get_vacation_off", STATE_UNKNOWN),
],
)
async def test_sensors(
hass: HomeAssistant, setup_integration: ComponentSetup, fixture: str, result: str
) -> None:
"""Test we get sensor data."""
await setup_integration()
@ -29,7 +40,7 @@ async def test_sensors(hass: HomeAssistant, setup_integration: ComponentSetup) -
"httplib2.Http.request",
return_value=(
Response({}),
bytes(load_fixture("google_mail/get_vacation_off.json"), encoding="UTF-8"),
bytes(load_fixture(f"google_mail/{fixture}.json"), encoding="UTF-8"),
),
):
next_update = dt_util.utcnow() + timedelta(minutes=15)
@ -37,7 +48,7 @@ async def test_sensors(hass: HomeAssistant, setup_integration: ComponentSetup) -
await hass.async_block_till_done()
state = hass.states.get(SENSOR)
assert state.state == STATE_UNKNOWN
assert state.state == result
async def test_sensor_reauth_trigger(