Fix script queued mode typo (#37759)

This commit is contained in:
Phil Bruckner 2020-07-11 13:34:53 -05:00 committed by GitHub
parent 690579749e
commit e5a081c7dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -52,12 +52,12 @@ from homeassistant.util.dt import utcnow
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
SCRIPT_MODE_PARALLEL = "parallel" SCRIPT_MODE_PARALLEL = "parallel"
SCRIPT_MODE_QUEUE = "queue" SCRIPT_MODE_QUEUED = "queued"
SCRIPT_MODE_RESTART = "restart" SCRIPT_MODE_RESTART = "restart"
SCRIPT_MODE_SINGLE = "single" SCRIPT_MODE_SINGLE = "single"
SCRIPT_MODE_CHOICES = [ SCRIPT_MODE_CHOICES = [
SCRIPT_MODE_PARALLEL, SCRIPT_MODE_PARALLEL,
SCRIPT_MODE_QUEUE, SCRIPT_MODE_QUEUED,
SCRIPT_MODE_RESTART, SCRIPT_MODE_RESTART,
SCRIPT_MODE_SINGLE, SCRIPT_MODE_SINGLE,
] ]
@ -580,7 +580,7 @@ class Script:
self._runs: List[_ScriptRun] = [] self._runs: List[_ScriptRun] = []
self._max_runs = max_runs self._max_runs = max_runs
if script_mode == SCRIPT_MODE_QUEUE: if script_mode == SCRIPT_MODE_QUEUED:
self._queue_lck = asyncio.Lock() self._queue_lck = asyncio.Lock()
self._config_cache: Dict[Set[Tuple], Callable[..., bool]] = {} self._config_cache: Dict[Set[Tuple], Callable[..., bool]] = {}
self._referenced_entities: Optional[Set[str]] = None self._referenced_entities: Optional[Set[str]] = None
@ -677,7 +677,7 @@ class Script:
self._log("Maximum number of runs exceeded", level=logging.WARNING) self._log("Maximum number of runs exceeded", level=logging.WARNING)
return return
if self._script_mode != SCRIPT_MODE_QUEUE: if self._script_mode != SCRIPT_MODE_QUEUED:
cls = _ScriptRun cls = _ScriptRun
else: else:
cls = _QueuedScriptRun cls = _QueuedScriptRun

View file

@ -1112,8 +1112,8 @@ async def test_script_mode_2(hass, caplog, script_mode, messages, last_events):
assert events[idx].data["value"] == value assert events[idx].data["value"] == value
async def test_script_mode_queue(hass): async def test_script_mode_queued(hass):
"""Test overlapping runs with script_mode = 'queue' & max_runs > 1.""" """Test overlapping runs with script_mode = 'queued' & max_runs > 1."""
event = "test_event" event = "test_event"
events = async_capture_events(hass, event) events = async_capture_events(hass, event)
sequence = cv.SCRIPT_SCHEMA( sequence = cv.SCRIPT_SCHEMA(
@ -1126,7 +1126,7 @@ async def test_script_mode_queue(hass):
) )
logger = logging.getLogger("TEST") logger = logging.getLogger("TEST")
script_obj = script.Script( script_obj = script.Script(
hass, sequence, script_mode="queue", max_runs=2, logger=logger hass, sequence, script_mode="queued", max_runs=2, logger=logger
) )
wait_started_flag = async_watch_for_action(script_obj, "wait") wait_started_flag = async_watch_for_action(script_obj, "wait")