deCONZ allow unloading of config entry (#14115)
* Working but incomplete * Remove events on unload * Add unload test * Fix failing sensor test * Improve unload test * Move DeconzEvent to init * Fix visual under-indentation
This commit is contained in:
parent
ef48a7ca2c
commit
3fd4987baf
8 changed files with 86 additions and 31 deletions
|
@ -107,3 +107,19 @@ async def test_setup_entry_successful(hass):
|
|||
(entry, 'scene')
|
||||
assert mock_config_entries.async_forward_entry_setup.mock_calls[3][1] == \
|
||||
(entry, 'sensor')
|
||||
|
||||
|
||||
async def test_unload_entry(hass):
|
||||
"""Test being able to unload an entry."""
|
||||
entry = Mock()
|
||||
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
|
||||
with patch('pydeconz.DeconzSession.async_load_parameters',
|
||||
return_value=mock_coro(True)):
|
||||
assert await deconz.async_setup_entry(hass, entry) is True
|
||||
assert deconz.DATA_DECONZ_EVENT in hass.data
|
||||
hass.data[deconz.DATA_DECONZ_EVENT].append(Mock())
|
||||
hass.data[deconz.DATA_DECONZ_ID] = {'id': 'deconzid'}
|
||||
assert await deconz.async_unload_entry(hass, entry)
|
||||
assert deconz.DOMAIN not in hass.data
|
||||
assert len(hass.data[deconz.DATA_DECONZ_EVENT]) == 0
|
||||
assert len(hass.data[deconz.DATA_DECONZ_ID]) == 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue