Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calling empty script turn off #24827

Merged
merged 1 commit into from Jun 28, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -79,9 +79,14 @@ def is_on(hass, entity_id):
async def turn_off_service(service):
"""Cancel a script."""
# Stopping a script is ok to be done in parallel
scripts = await component.async_extract_from_service(service)

if not scripts:
return

await asyncio.wait([
script.async_turn_off() for script
in await component.async_extract_from_service(service)
in scripts
])

async def toggle_service(service):
@@ -322,3 +322,13 @@ def test_reload_service(self):
assert err.value.domain == 'non'
assert err.value.service == 'existing'
assert 'Error executing script' in caplog.text


async def test_turning_no_scripts_off(hass):
"""Test it is possible to turn two scripts off."""
assert await async_setup_component(hass, 'script', {})

# Testing it doesn't raise
await hass.services.async_call(
DOMAIN, SERVICE_TURN_OFF, {'entity_id': []}, blocking=True
)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.