Fix returned value from backup/info WS command (#67439)
parent
94130a6060
commit
e58ce7ab6e
|
@ -5,6 +5,7 @@ from dataclasses import asdict, dataclass
|
|||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import tarfile
|
||||
from tarfile import TarError
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
|
@ -51,7 +52,7 @@ class BackupManager:
|
|||
def _read_backups() -> None:
|
||||
for backup_path in self.backup_dir.glob("*.tar"):
|
||||
try:
|
||||
with SecureTarFile(backup_path, "r", gzip=False) as backup_file:
|
||||
with tarfile.open(backup_path, "r:") as backup_file:
|
||||
if data_file := backup_file.extractfile("./backup.json"):
|
||||
data = json.loads(data_file.read())
|
||||
backup = Backup(
|
||||
|
|
|
@ -30,7 +30,7 @@ async def handle_info(
|
|||
connection.send_result(
|
||||
msg["id"],
|
||||
{
|
||||
"backups": list(backups),
|
||||
"backups": list(backups.values()),
|
||||
"backing_up": manager.backing_up,
|
||||
},
|
||||
)
|
||||
|
|
|
@ -20,12 +20,17 @@ async def test_info(
|
|||
client = await hass_ws_client(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await client.send_json({"id": 1, "type": "backup/info"})
|
||||
msg = await client.receive_json()
|
||||
with patch(
|
||||
"homeassistant.components.backup.websocket.BackupManager.get_backups",
|
||||
return_value={TEST_BACKUP.slug: TEST_BACKUP},
|
||||
):
|
||||
|
||||
await client.send_json({"id": 1, "type": "backup/info"})
|
||||
msg = await client.receive_json()
|
||||
|
||||
assert msg["id"] == 1
|
||||
assert msg["success"]
|
||||
assert msg["result"] == {"backing_up": False, "backups": []}
|
||||
assert msg["result"] == {"backing_up": False, "backups": [TEST_BACKUP.as_dict()]}
|
||||
|
||||
|
||||
async def test_remove(
|
||||
|
|
Loading…
Reference in New Issue