* Implement WS API endpoints for zigpy backups * Implement backup restoration * Display error messages caused by invalid backup JSON * Indicate to the frontend when a backup is incomplete * Perform a coordinator backup before HA performs a backup * Fix `backup.async_post_backup` docstring * Rename `data` to `backup` in restore command * Add unit tests for new websocket APIs * Unit test backup platform * Move code to overwrite EZSP EUI64 into ZHA * Include the radio type in the network settings API response
20 lines
640 B
Python
20 lines
640 B
Python
"""Unit tests for ZHA backup platform."""
|
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
from homeassistant.components.zha.backup import async_post_backup, async_pre_backup
|
|
|
|
|
|
async def test_pre_backup(hass, setup_zha):
|
|
"""Test backup creation when `async_pre_backup` is called."""
|
|
with patch("zigpy.backups.BackupManager.create_backup", AsyncMock()) as backup_mock:
|
|
await setup_zha()
|
|
await async_pre_backup(hass)
|
|
|
|
backup_mock.assert_called_once_with(load_devices=True)
|
|
|
|
|
|
async def test_post_backup(hass, setup_zha):
|
|
"""Test no-op `async_post_backup`."""
|
|
await setup_zha()
|
|
await async_post_backup(hass)
|