mirror of
https://github.com/elisspace/core.git
synced 2026-09-16 07:53:04 +00:00
Fix local calendar issue with events created with fixed UTC offsets (#88650)
Fix issue with events created with UTC offsets
This commit is contained in:
committed by
Paulus Schoutsen
parent
951df3df57
commit
2fddbcedcf
@@ -310,6 +310,30 @@ async def test_unsupported_create_event_service(hass: HomeAssistant) -> None:
|
||||
vol.error.MultipleInvalid,
|
||||
"must contain at most one of start_date, start_date_time, in.",
|
||||
),
|
||||
(
|
||||
{
|
||||
"start_date_time": "2022-04-01T06:00:00+00:00",
|
||||
"end_date_time": "2022-04-01T07:00:00+01:00",
|
||||
},
|
||||
vol.error.MultipleInvalid,
|
||||
"Expected all values to have the same timezone",
|
||||
),
|
||||
(
|
||||
{
|
||||
"start_date_time": "2022-04-01T07:00:00",
|
||||
"end_date_time": "2022-04-01T06:00:00",
|
||||
},
|
||||
vol.error.MultipleInvalid,
|
||||
"Values were not in order",
|
||||
),
|
||||
(
|
||||
{
|
||||
"start_date": "2022-04-02",
|
||||
"end_date": "2022-04-01",
|
||||
},
|
||||
vol.error.MultipleInvalid,
|
||||
"Values were not in order",
|
||||
),
|
||||
],
|
||||
ids=[
|
||||
"missing_all",
|
||||
@@ -324,6 +348,9 @@ async def test_unsupported_create_event_service(hass: HomeAssistant) -> None:
|
||||
"multiple_in",
|
||||
"unexpected_in_with_date",
|
||||
"unexpected_in_with_datetime",
|
||||
"inconsistent_timezone",
|
||||
"incorrect_date_order",
|
||||
"incorrect_datetime_order",
|
||||
],
|
||||
)
|
||||
async def test_create_event_service_invalid_params(
|
||||
|
||||
@@ -48,8 +48,12 @@ class FakeStore(LocalCalendarStore):
|
||||
def mock_store() -> None:
|
||||
"""Test cleanup, remove any media storage persisted during the test."""
|
||||
|
||||
stores: dict[Path, FakeStore] = {}
|
||||
|
||||
def new_store(hass: HomeAssistant, path: Path) -> FakeStore:
|
||||
return FakeStore(hass, path)
|
||||
if path not in stores:
|
||||
stores[path] = FakeStore(hass, path)
|
||||
return stores[path]
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.local_calendar.LocalCalendarStore", new=new_store
|
||||
@@ -961,8 +965,20 @@ async def test_update_invalid_event_id(
|
||||
assert resp.get("error").get("code") == "failed"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("start_date_time", "end_date_time"),
|
||||
[
|
||||
("1997-07-14T17:00:00+00:00", "1997-07-15T04:00:00+00:00"),
|
||||
("1997-07-14T11:00:00-06:00", "1997-07-14T22:00:00-06:00"),
|
||||
],
|
||||
)
|
||||
async def test_create_event_service(
|
||||
hass: HomeAssistant, setup_integration: None, get_events: GetEventsFn
|
||||
hass: HomeAssistant,
|
||||
setup_integration: None,
|
||||
get_events: GetEventsFn,
|
||||
start_date_time: str,
|
||||
end_date_time: str,
|
||||
config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test creating an event using the create_event service."""
|
||||
|
||||
@@ -970,13 +986,15 @@ async def test_create_event_service(
|
||||
"calendar",
|
||||
"create_event",
|
||||
{
|
||||
"start_date_time": "1997-07-14T17:00:00+00:00",
|
||||
"end_date_time": "1997-07-15T04:00:00+00:00",
|
||||
"start_date_time": start_date_time,
|
||||
"end_date_time": end_date_time,
|
||||
"summary": "Bastille Day Party",
|
||||
},
|
||||
target={"entity_id": TEST_ENTITY},
|
||||
blocking=True,
|
||||
)
|
||||
# Ensure data is written to disk
|
||||
await hass.async_block_till_done()
|
||||
|
||||
events = await get_events("1997-07-14T00:00:00Z", "1997-07-16T00:00:00Z")
|
||||
assert list(map(event_fields, events)) == [
|
||||
@@ -995,3 +1013,17 @@ async def test_create_event_service(
|
||||
"end": {"dateTime": "1997-07-14T22:00:00-06:00"},
|
||||
}
|
||||
]
|
||||
|
||||
# Reload the config entry, which reloads the content from the store and
|
||||
# verifies that the persisted data can be parsed correctly.
|
||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
events = await get_events("1997-07-13T00:00:00Z", "1997-07-14T18:00:00Z")
|
||||
assert list(map(event_fields, events)) == [
|
||||
{
|
||||
"summary": "Bastille Day Party",
|
||||
"start": {"dateTime": "1997-07-14T11:00:00-06:00"},
|
||||
"end": {"dateTime": "1997-07-14T22:00:00-06:00"},
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user