Add google calendar required feature for create event service (#101741)

* Add google calendar required feature for create event service

* Update docstring
pull/101800/head^2
Allen Porter 2023-10-10 20:48:46 -07:00 committed by GitHub
parent ffb752c804
commit bd38fd9516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 0 deletions

View File

@ -240,6 +240,7 @@ async def async_setup_entry(
SERVICE_CREATE_EVENT,
CREATE_EVENT_SCHEMA,
async_create_event,
required_features=CalendarEntityFeature.CREATE_EVENT,
)

View File

@ -576,6 +576,59 @@ async def test_add_event_date_time(
}
@pytest.mark.parametrize(
"calendars_config",
[
[
{
"cal_id": CALENDAR_ID,
"entities": [
{
"device_id": "backyard_light",
"name": "Backyard Light",
"search": "#Backyard",
},
],
}
],
],
)
async def test_unsupported_create_event(
hass: HomeAssistant,
mock_calendars_yaml: Mock,
component_setup: ComponentSetup,
mock_calendars_list: ApiResult,
mock_insert_event: Callable[[str, dict[str, Any]], None],
test_api_calendar: dict[str, Any],
mock_events_list: ApiResult,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""Test create event service call is unsupported for virtual calendars."""
mock_calendars_list({"items": [test_api_calendar]})
mock_events_list({})
assert await component_setup()
start_datetime = datetime.datetime.now(tz=zoneinfo.ZoneInfo("America/Regina"))
delta = datetime.timedelta(days=3, hours=3)
end_datetime = start_datetime + delta
with pytest.raises(HomeAssistantError, match="does not support this service"):
await hass.services.async_call(
DOMAIN,
"create_event",
{
# **data,
"start_date_time": start_datetime.isoformat(),
"end_date_time": end_datetime.isoformat(),
"summary": TEST_EVENT_SUMMARY,
"description": TEST_EVENT_DESCRIPTION,
},
target={"entity_id": "calendar.backyard_light"},
blocking=True,
)
async def test_add_event_failure(
hass: HomeAssistant,
component_setup: ComponentSetup,