Rename remove backup to delete backup (#130940)

* Rename remove backup to delete backup

* Revert "backup/delete"
This commit is contained in:
Martin Hjelmare
2024-11-19 15:18:05 +01:00
committed by GitHub
parent 777e3c82f2
commit 4a44d19c53
7 changed files with 451 additions and 451 deletions

View File

@@ -134,5 +134,5 @@ class CoreLocalBackupAgent(LocalBackupAgent):
backup_path = self.get_backup_path(backup_id)
await self._hass.async_add_executor_job(backup_path.unlink, True)
LOGGER.debug("Removed backup located at %s", backup_path)
LOGGER.debug("Deleted backup located at %s", backup_path)
self._backups.pop(backup_id)

View File

@@ -228,8 +228,8 @@ class BaseBackupManager(abc.ABC, Generic[_BackupT]):
"""Get a backup."""
@abc.abstractmethod
async def async_remove_backup(self, backup_id: str, **kwargs: Any) -> None:
"""Remove a backup."""
async def async_delete_backup(self, backup_id: str, **kwargs: Any) -> None:
"""Delete a backup."""
@abc.abstractmethod
async def async_receive_backup(
@@ -353,8 +353,8 @@ class BackupManager(BaseBackupManager[Backup]):
return (backup, agent_errors)
async def async_remove_backup(self, backup_id: str, **kwargs: Any) -> None:
"""Remove a backup."""
async def async_delete_backup(self, backup_id: str, **kwargs: Any) -> None:
"""Delete a backup."""
for agent in self.backup_agents.values():
await agent.async_delete_backup(backup_id)

View File

@@ -26,7 +26,7 @@ def async_register_websocket_handlers(hass: HomeAssistant, with_hassio: bool) ->
websocket_api.async_register_command(hass, handle_details)
websocket_api.async_register_command(hass, handle_info)
websocket_api.async_register_command(hass, handle_create)
websocket_api.async_register_command(hass, handle_remove)
websocket_api.async_register_command(hass, handle_delete)
websocket_api.async_register_command(hass, handle_restore)
websocket_api.async_register_command(hass, handle_config_info)
@@ -92,13 +92,13 @@ async def handle_details(
}
)
@websocket_api.async_response
async def handle_remove(
async def handle_delete(
hass: HomeAssistant,
connection: websocket_api.ActiveConnection,
msg: dict[str, Any],
) -> None:
"""Remove a backup."""
await hass.data[DATA_MANAGER].async_remove_backup(msg["backup_id"])
"""Delete a backup."""
await hass.data[DATA_MANAGER].async_delete_backup(msg["backup_id"])
connection.send_result(msg["id"])

View File

@@ -1,4 +1,12 @@
# serializer version: 1
# name: test_agent_delete_backup
dict({
'id': 1,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_agents_download[with_hassio]
dict({
'id': 1,
@@ -330,6 +338,422 @@
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents0-backups0]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents0-backups0].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents0-backups0].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents1-backups1]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents1-backups1].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents1-backups1].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents2-backups2]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents2-backups2].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents2-backups2].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents3-backups3]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents3-backups3].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents3-backups3].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents4-backups4]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents4-backups4].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[with_hassio-remote_agents4-backups4].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents0-backups0]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents0-backups0].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents0-backups0].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents1-backups1]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'backup.local',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents1-backups1].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents1-backups1].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents2-backups2]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents2-backups2].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents2-backups2].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents3-backups3]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'def456',
'date': '1980-01-01T00:00:00.000Z',
'name': 'Test 2',
'protected': False,
'size': 1.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents3-backups3].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents3-backups3].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'def456',
'date': '1980-01-01T00:00:00.000Z',
'name': 'Test 2',
'protected': False,
'size': 1.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents4-backups4]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
'backup.local',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents4-backups4].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_delete[without_hassio-remote_agents4-backups4].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_details[with_hassio-remote_agents0-backups0]
dict({
'error': dict({
@@ -808,430 +1232,6 @@
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents0-backups0]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents0-backups0].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents0-backups0].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents1-backups1]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents1-backups1].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents1-backups1].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents2-backups2]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents2-backups2].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents2-backups2].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents3-backups3]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents3-backups3].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents3-backups3].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents4-backups4]
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 1,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents4-backups4].1
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 2,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[with_hassio-remote_agents4-backups4].2
dict({
'error': dict({
'code': 'unknown_command',
'message': 'Unknown command.',
}),
'id': 3,
'success': False,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents0-backups0]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents0-backups0].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents0-backups0].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents1-backups1]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'backup.local',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents1-backups1].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents1-backups1].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents2-backups2]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents2-backups2].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents2-backups2].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents3-backups3]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'def456',
'date': '1980-01-01T00:00:00.000Z',
'name': 'Test 2',
'protected': False,
'size': 1.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents3-backups3].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents3-backups3].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'def456',
'date': '1980-01-01T00:00:00.000Z',
'name': 'Test 2',
'protected': False,
'size': 1.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents4-backups4]
dict({
'id': 1,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
'backup.local',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents4-backups4].1
dict({
'id': 2,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_remove[without_hassio-remote_agents4-backups4].2
dict({
'id': 3,
'result': dict({
'agent_errors': dict({
}),
'backing_up': False,
'backups': list([
dict({
'agent_ids': list([
'test.remote',
]),
'backup_id': 'abc123',
'date': '1970-01-01T00:00:00.000Z',
'name': 'Test',
'protected': False,
'size': 0.0,
}),
]),
}),
'success': True,
'type': 'result',
})
# ---
# name: test_remove_agents_delete
dict({
'id': 1,
'result': None,
'success': True,
'type': 'result',
})
# ---
# name: test_restore_local_agent[with_hassio-backups0]
dict({
'error': dict({

View File

@@ -189,11 +189,11 @@ async def test_load_backups_with_exception(
assert agent_errors == {}
async def test_removing_backup(
async def test_deleting_backup(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test removing backup."""
"""Test deleting backup."""
manager = BackupManager(hass)
await _setup_backup_platform(hass, domain=DOMAIN, platform=local_backup_platform)
@@ -204,22 +204,22 @@ async def test_removing_backup(
local_agent._loaded_backups = True
with patch("pathlib.Path.exists", return_value=True):
await manager.async_remove_backup(TEST_BASE_BACKUP_ABC123.backup_id)
assert "Removed backup located at" in caplog.text
await manager.async_delete_backup(TEST_BASE_BACKUP_ABC123.backup_id)
assert "Deleted backup located at" in caplog.text
async def test_removing_non_existing_backup(
async def test_deleting_non_existing_backup(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test removing not existing backup."""
"""Test deleting not existing backup."""
manager = BackupManager(hass)
await _setup_backup_platform(hass, domain=DOMAIN, platform=local_backup_platform)
await manager.load_platforms()
await manager.async_remove_backup("non_existing")
assert "Removed backup located at" not in caplog.text
await manager.async_delete_backup("non_existing")
assert "Deleted backup located at" not in caplog.text
async def test_getting_backup_that_does_not_exist(

View File

@@ -198,7 +198,7 @@ async def test_details_with_errors(
pytest.param(False, id="without_hassio"),
],
)
async def test_remove(
async def test_delete(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
with_hassio: bool,
@@ -206,7 +206,7 @@ async def test_remove(
backups: dict[str, BaseBackup],
snapshot: SnapshotAssertion,
) -> None:
"""Test removing a backup file."""
"""Test deleting a backup file."""
await setup_backup_integration(
hass, with_hassio=with_hassio, backups=backups, remote_agents=remote_agents
)
@@ -224,12 +224,12 @@ async def test_remove(
assert await client.receive_json() == snapshot
async def test_remove_agents_delete(
async def test_agent_delete_backup(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
snapshot: SnapshotAssertion,
) -> None:
"""Test removing a backup file with a mock agent."""
"""Test deleting a backup file with a mock agent."""
await setup_backup_integration(hass)
hass.data[DATA_MANAGER].backup_agents = {"domain.test": BackupAgentTest("test")}

View File

@@ -41,7 +41,7 @@ async def test_agents_info(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test backup agents info."""
"""Test backup agent info."""
client = await hass_ws_client(hass)
await client.send_json_auto_id({"type": "backup/agents/info"})
@@ -58,7 +58,7 @@ async def test_agents_list_backups(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test backup agents list backups."""
"""Test agent list backups."""
client = await hass_ws_client(hass)
await client.send_json_auto_id({"type": "backup/agents/list_backups"})
@@ -82,7 +82,7 @@ async def test_agents_download(
hass_ws_client: WebSocketGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test backup agents download."""
"""Test agent download backup."""
client = await hass_ws_client(hass)
backup_id = "abc123"
@@ -107,7 +107,7 @@ async def test_agents_upload(
caplog: pytest.LogCaptureFixture,
hass_supervisor_access_token: str,
) -> None:
"""Test backup agents upload."""
"""Test agent upload backup."""
ws_client = await hass_ws_client(hass, hass_supervisor_access_token)
client = await hass_client()
backup_id = "test-backup"
@@ -154,12 +154,12 @@ async def test_agents_upload(
}
async def test_agents_delete(
async def test_agent_delete_backup(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test backup agents delete."""
"""Test agent delete backup."""
client = await hass_ws_client(hass)
backup_id = "abc123"