mirror of
https://github.com/home-assistant/supervisor.git
synced 2026-08-19 20:58:18 +01:00
* Fix typos in comments, docstrings and log messages Correct 39 spelling mistakes across comments, docstrings and log/error message strings throughout the package (e.g. "conection" -> "connection", "Incomming" -> "Incoming", "Rasie" -> "Raise"). All changes are confined to human-readable text; no identifiers, attributes or D-Bus contracts are touched, so there is no behavior change. Found with codespell. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix typos in tests and CI workflow Correct spelling mistakes in test comments, docstrings and data, plus one in the builder workflow, so the whole tree is clean for the codespell hook added next. The assertion in test_network_manager.py is updated to match the corrected "Unknown error while processing" log message in the source. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Add codespell pre-commit hook Wire up codespell so spelling mistakes in comments, docstrings and strings are caught automatically. The vendored frontend panel is excluded, and "hass" and "astroid" are added to the ignore list as known false positives (the Home Assistant abbreviation and the pylint dependency package). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Address review feedback Improve grammar in several of the touched comments and docstrings: use the plural "ignore conditions" for the list-returning property, add the missing auxiliary verb and fix agreement in the timezone-filter comment, fix "backups ... use" agreement, and reword "underlay" to "underlying" in the arch module docstring. Also drop the "*.json" skip from the codespell hook. It was carried over from another project but is unnecessary here (all tracked JSON is clean), and skipping it would needlessly leave translation and data JSON unchecked. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Reword onboarding comment "overflight" was a literal calque of the German "überflogen"; use the idiomatic "skimmed through" instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
78 lines
1.8 KiB
Python
78 lines
1.8 KiB
Python
"""Test Supervisor scheduler backend."""
|
|
|
|
import asyncio
|
|
|
|
from supervisor.const import CoreState
|
|
|
|
|
|
async def test_simple_task(coresys):
|
|
"""Schedule a simple task."""
|
|
await coresys.core.set_state(CoreState.RUNNING)
|
|
trigger = []
|
|
|
|
async def test_task():
|
|
"""Test task for schedule."""
|
|
trigger.append(True)
|
|
|
|
coresys.scheduler.register_task(test_task, 0.1, False)
|
|
await asyncio.sleep(0.3)
|
|
|
|
assert len(trigger) == 1
|
|
|
|
|
|
async def test_simple_task_repeat(coresys):
|
|
"""Schedule a simple task and repeat."""
|
|
await coresys.core.set_state(CoreState.RUNNING)
|
|
trigger = []
|
|
|
|
async def test_task():
|
|
"""Test task for schedule."""
|
|
trigger.append(True)
|
|
|
|
coresys.scheduler.register_task(test_task, 0.1, True)
|
|
|
|
for _ in range(5):
|
|
await asyncio.sleep(0.1)
|
|
if len(trigger) > 1:
|
|
break
|
|
|
|
assert len(trigger) > 1
|
|
|
|
|
|
async def test_simple_task_shutdown(coresys):
|
|
"""Schedule a simple task with shutdown."""
|
|
await coresys.core.set_state(CoreState.RUNNING)
|
|
trigger = []
|
|
|
|
async def test_task():
|
|
"""Test task for schedule."""
|
|
trigger.append(True)
|
|
|
|
coresys.scheduler.register_task(test_task, 0.1, True)
|
|
await asyncio.sleep(0.3)
|
|
await coresys.scheduler.shutdown()
|
|
|
|
assert len(trigger) > 1
|
|
|
|
old = len(trigger)
|
|
await asyncio.sleep(0.2)
|
|
|
|
assert len(trigger) == old
|
|
|
|
|
|
async def test_simple_task_repeat_block(coresys):
|
|
"""Schedule a simple task with repeat and block."""
|
|
await coresys.core.set_state(CoreState.RUNNING)
|
|
trigger = []
|
|
|
|
async def test_task():
|
|
"""Test task for schedule."""
|
|
trigger.append(True)
|
|
await asyncio.sleep(2)
|
|
|
|
coresys.scheduler.register_task(test_task, 0.1, True)
|
|
await asyncio.sleep(0.3)
|
|
|
|
assert len(trigger) == 1
|
|
await coresys.scheduler.shutdown()
|