Add google calendar required feature for create event service (#101741)
* Add google calendar required feature for create event service * Update docstringpull/101800/head^2
parent
ffb752c804
commit
bd38fd9516
|
@ -240,6 +240,7 @@ async def async_setup_entry(
|
||||||
SERVICE_CREATE_EVENT,
|
SERVICE_CREATE_EVENT,
|
||||||
CREATE_EVENT_SCHEMA,
|
CREATE_EVENT_SCHEMA,
|
||||||
async_create_event,
|
async_create_event,
|
||||||
|
required_features=CalendarEntityFeature.CREATE_EVENT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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(
|
async def test_add_event_failure(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
component_setup: ComponentSetup,
|
component_setup: ComponentSetup,
|
||||||
|
|
Loading…
Reference in New Issue