mirror of
https://github.com/home-assistant/core.git
synced 2025-11-07 01:50:18 +00:00
Allow deletion of automations and scripts (#23845)
This commit is contained in:
committed by
Pascal Vizeli
parent
6f9860b25e
commit
a859997190
41
tests/components/config/test_script.py
Normal file
41
tests/components/config/test_script.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""Tests for config/script."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components import config
|
||||
|
||||
|
||||
async def test_delete_script(hass, hass_client):
|
||||
"""Test deleting a script."""
|
||||
with patch.object(config, 'SECTIONS', ['script']):
|
||||
await async_setup_component(hass, 'config', {})
|
||||
|
||||
client = await hass_client()
|
||||
|
||||
orig_data = {
|
||||
'one': {},
|
||||
'two': {},
|
||||
}
|
||||
|
||||
def mock_read(path):
|
||||
"""Mock reading data."""
|
||||
return orig_data
|
||||
|
||||
written = []
|
||||
|
||||
def mock_write(path, data):
|
||||
"""Mock writing data."""
|
||||
written.append(data)
|
||||
|
||||
with patch('homeassistant.components.config._read', mock_read), \
|
||||
patch('homeassistant.components.config._write', mock_write):
|
||||
resp = await client.delete('/api/config/script/config/two')
|
||||
|
||||
assert resp.status == 200
|
||||
result = await resp.json()
|
||||
assert result == {'result': 'ok'}
|
||||
|
||||
assert len(written) == 1
|
||||
assert written[0] == {
|
||||
'one': {}
|
||||
}
|
||||
Reference in New Issue
Block a user