mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Revert google calendar back to old API for free/busy readers (#81894)
* Revert google calendar back to old API for free/busy readers * Update homeassistant/components/google/calendar.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
a2da1c7db5
commit
e6d1a4a422
@ -10,7 +10,7 @@ from typing import Any
|
|||||||
|
|
||||||
from gcal_sync.api import GoogleCalendarService, ListEventsRequest, SyncEventsRequest
|
from gcal_sync.api import GoogleCalendarService, ListEventsRequest, SyncEventsRequest
|
||||||
from gcal_sync.exceptions import ApiException
|
from gcal_sync.exceptions import ApiException
|
||||||
from gcal_sync.model import DateOrDatetime, Event
|
from gcal_sync.model import AccessRole, DateOrDatetime, Event
|
||||||
from gcal_sync.store import ScopedCalendarStore
|
from gcal_sync.store import ScopedCalendarStore
|
||||||
from gcal_sync.sync import CalendarEventSyncManager
|
from gcal_sync.sync import CalendarEventSyncManager
|
||||||
from gcal_sync.timeline import Timeline
|
from gcal_sync.timeline import Timeline
|
||||||
@ -198,7 +198,13 @@ async def async_setup_entry(
|
|||||||
entity_entry.entity_id,
|
entity_entry.entity_id,
|
||||||
)
|
)
|
||||||
coordinator: CalendarSyncUpdateCoordinator | CalendarQueryUpdateCoordinator
|
coordinator: CalendarSyncUpdateCoordinator | CalendarQueryUpdateCoordinator
|
||||||
if search := data.get(CONF_SEARCH):
|
# Prefer calendar sync down of resources when possible. However, sync does not work
|
||||||
|
# for search. Also free-busy calendars denormalize recurring events as individual
|
||||||
|
# events which is not efficient for sync
|
||||||
|
if (
|
||||||
|
search := data.get(CONF_SEARCH)
|
||||||
|
or calendar_item.access_role == AccessRole.FREE_BUSY_READER
|
||||||
|
):
|
||||||
coordinator = CalendarQueryUpdateCoordinator(
|
coordinator = CalendarQueryUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
calendar_service,
|
calendar_service,
|
||||||
|
@ -47,7 +47,6 @@ TEST_API_CALENDAR = {
|
|||||||
"id": CALENDAR_ID,
|
"id": CALENDAR_ID,
|
||||||
"etag": '"3584134138943410"',
|
"etag": '"3584134138943410"',
|
||||||
"timeZone": "UTC",
|
"timeZone": "UTC",
|
||||||
"accessRole": "reader",
|
|
||||||
"foregroundColor": "#000000",
|
"foregroundColor": "#000000",
|
||||||
"selected": True,
|
"selected": True,
|
||||||
"kind": "calendar#calendarListEntry",
|
"kind": "calendar#calendarListEntry",
|
||||||
@ -62,10 +61,19 @@ CLIENT_ID = "client-id"
|
|||||||
CLIENT_SECRET = "client-secret"
|
CLIENT_SECRET = "client-secret"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name="calendar_access_role")
|
||||||
|
def test_calendar_access_role() -> str:
|
||||||
|
"""Default access role to use for test_api_calendar in tests."""
|
||||||
|
return "reader"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_api_calendar():
|
def test_api_calendar(calendar_access_role: str):
|
||||||
"""Return a test calendar object used in API responses."""
|
"""Return a test calendar object used in API responses."""
|
||||||
return TEST_API_CALENDAR
|
return {
|
||||||
|
**TEST_API_CALENDAR,
|
||||||
|
"accessRole": calendar_access_role,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -60,6 +60,14 @@ TEST_EVENT = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(
|
||||||
|
autouse=True, scope="module", params=["reader", "owner", "freeBusyReader"]
|
||||||
|
)
|
||||||
|
def calendar_access_role(request) -> str:
|
||||||
|
"""Fixture to exercise access roles in tests."""
|
||||||
|
return request.param
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_test_setup(
|
def mock_test_setup(
|
||||||
test_api_calendar,
|
test_api_calendar,
|
||||||
@ -716,12 +724,15 @@ async def test_invalid_unique_id_cleanup(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"time_zone,event_order",
|
"time_zone,event_order,calendar_access_role",
|
||||||
|
# This only tests the reader role to force testing against the local
|
||||||
|
# database filtering based on start/end time. (free busy reader would
|
||||||
|
# just use the API response which this test is not exercising)
|
||||||
[
|
[
|
||||||
("America/Los_Angeles", ["One", "Two", "All Day Event"]),
|
("America/Los_Angeles", ["One", "Two", "All Day Event"], "reader"),
|
||||||
("America/Regina", ["One", "Two", "All Day Event"]),
|
("America/Regina", ["One", "Two", "All Day Event"], "reader"),
|
||||||
("UTC", ["One", "All Day Event", "Two"]),
|
("UTC", ["One", "All Day Event", "Two"], "reader"),
|
||||||
("Asia/Tokyo", ["All Day Event", "One", "Two"]),
|
("Asia/Tokyo", ["All Day Event", "One", "Two"], "reader"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_all_day_iter_order(
|
async def test_all_day_iter_order(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user