mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Fix google calendar working location event filtering (#141222)
This commit is contained in:
parent
f14b76c54b
commit
c451518959
@ -383,9 +383,9 @@ class GoogleCalendarEntity(
|
||||
for attendee in event.attendees
|
||||
):
|
||||
return False
|
||||
|
||||
if event.event_type == EventTypeEnum.WORKING_LOCATION:
|
||||
return self.entity_description.working_location
|
||||
is_working_location_event = event.event_type == EventTypeEnum.WORKING_LOCATION
|
||||
if self.entity_description.working_location != is_working_location_event:
|
||||
return False
|
||||
if self._ignore_availability:
|
||||
return True
|
||||
return event.transparency == OPAQUE
|
||||
|
@ -1451,6 +1451,13 @@ async def test_working_location_ignored(
|
||||
assert state.attributes.get("message") == expected_event_message
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("event_type", "expected_event_message"),
|
||||
[
|
||||
("workingLocation", "Test All Day Event"),
|
||||
("default", None),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize("calendar_is_primary", [True])
|
||||
async def test_working_location_entity(
|
||||
hass: HomeAssistant,
|
||||
@ -1458,12 +1465,14 @@ async def test_working_location_entity(
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_events_list_items: Callable[[list[dict[str, Any]]], None],
|
||||
component_setup: ComponentSetup,
|
||||
event_type: str,
|
||||
expected_event_message: str | None,
|
||||
) -> None:
|
||||
"""Test that working location events are registered under a disabled by default entity."""
|
||||
event = {
|
||||
**TEST_EVENT,
|
||||
**upcoming(),
|
||||
"eventType": "workingLocation",
|
||||
"eventType": event_type,
|
||||
}
|
||||
mock_events_list_items([event])
|
||||
assert await component_setup()
|
||||
@ -1484,7 +1493,7 @@ async def test_working_location_entity(
|
||||
state = hass.states.get("calendar.working_location")
|
||||
assert state
|
||||
assert state.name == "Working location"
|
||||
assert state.attributes.get("message") == "Test All Day Event"
|
||||
assert state.attributes.get("message") == expected_event_message
|
||||
|
||||
|
||||
@pytest.mark.parametrize("calendar_is_primary", [False])
|
||||
|
Loading…
x
Reference in New Issue
Block a user