Fix blocking I/O in event loop in kira test (#121127)

This commit is contained in:
J. Nick Koston 2024-07-03 15:35:02 -07:00 committed by GitHub
parent 408e524551
commit 595e688c56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
"""The tests for Kira.""" """The tests for Kira."""
import os import os
from pathlib import Path
import shutil import shutil
import tempfile import tempfile
from unittest.mock import patch from unittest.mock import patch
@ -76,10 +77,9 @@ async def test_kira_creates_codes(work_dir) -> None:
assert os.path.exists(code_path), "Kira component didn't create codes file" assert os.path.exists(code_path), "Kira component didn't create codes file"
async def test_load_codes(work_dir) -> None: async def test_load_codes(hass: HomeAssistant, work_dir) -> None:
"""Kira should ignore invalid codes.""" """Kira should ignore invalid codes."""
code_path = os.path.join(work_dir, "codes.yaml") code_path = os.path.join(work_dir, "codes.yaml")
with open(code_path, "w", encoding="utf8") as code_file: await hass.async_add_executor_job(Path(code_path).write_text, KIRA_CODES)
code_file.write(KIRA_CODES)
res = kira.load_codes(code_path) res = kira.load_codes(code_path)
assert len(res) == 1, "Expected exactly 1 valid Kira code" assert len(res) == 1, "Expected exactly 1 valid Kira code"