mirror of
https://github.com/home-assistant/core.git
synced 2026-09-20 00:33:56 +01:00
Update local_todo to explicitly specify UTF-8 encoding for ICS storage (#181578)
This commit is contained in:
@@ -24,7 +24,7 @@ class LocalTodoListStore:
|
||||
"""Load the calendar from disk."""
|
||||
if not self._path.exists():
|
||||
return ""
|
||||
return self._path.read_text()
|
||||
return self._path.read_text(encoding="utf-8")
|
||||
|
||||
async def async_store(self, ics_content: str) -> None:
|
||||
"""Persist the calendar to storage."""
|
||||
@@ -33,4 +33,4 @@ class LocalTodoListStore:
|
||||
|
||||
def _store(self, ics_content: str) -> None:
|
||||
"""Persist the calendar to storage."""
|
||||
self._path.write_text(ics_content)
|
||||
self._path.write_text(ics_content, encoding="utf-8")
|
||||
|
||||
@@ -55,7 +55,9 @@ class FakeStore(LocalTodoListStore):
|
||||
def _mock_exists(self) -> bool:
|
||||
return self._mock_path.read_text.return_value is not None
|
||||
|
||||
def _mock_write_text(self, content: str) -> None:
|
||||
def _mock_write_text(self, content: str, encoding: str | None = None) -> None:
|
||||
if encoding is None:
|
||||
content.encode("ascii")
|
||||
self._mock_path.read_text.return_value = content
|
||||
|
||||
|
||||
|
||||
@@ -98,6 +98,10 @@ EXPECTED_ADD_ITEM = {
|
||||
),
|
||||
({ATTR_DESCRIPTION: ""}, {**EXPECTED_ADD_ITEM, "description": ""}),
|
||||
({ATTR_DESCRIPTION: None}, EXPECTED_ADD_ITEM),
|
||||
(
|
||||
{ATTR_ITEM: "测试主卧清扫"},
|
||||
{**EXPECTED_ADD_ITEM, "summary": "测试主卧清扫"},
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_add_item(
|
||||
|
||||
Reference in New Issue
Block a user