mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix blocking I/O in event loop in kira test (#121127)
This commit is contained in:
parent
408e524551
commit
595e688c56
@ -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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user