mirror of
https://github.com/home-assistant/core.git
synced 2025-08-11 08:35:15 +02:00
Disable core local backup agent in hassio (#130933)
This commit is contained in:
@@ -8,6 +8,7 @@ from tarfile import TarError
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.hassio import is_hassio
|
||||||
|
|
||||||
from .agent import BackupAgent, LocalBackupAgent
|
from .agent import BackupAgent, LocalBackupAgent
|
||||||
from .const import LOGGER
|
from .const import LOGGER
|
||||||
@@ -20,6 +21,8 @@ async def async_get_backup_agents(
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> list[BackupAgent]:
|
) -> list[BackupAgent]:
|
||||||
"""Return the local backup agent."""
|
"""Return the local backup agent."""
|
||||||
|
if is_hassio(hass):
|
||||||
|
return []
|
||||||
return [CoreLocalBackupAgent(hass)]
|
return [CoreLocalBackupAgent(hass)]
|
||||||
|
|
||||||
|
|
||||||
|
@@ -116,7 +116,12 @@ async def setup_backup_integration(
|
|||||||
remote_agents: list[str] | None = None,
|
remote_agents: list[str] | None = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Set up the Backup integration."""
|
"""Set up the Backup integration."""
|
||||||
with patch("homeassistant.components.backup.is_hassio", return_value=with_hassio):
|
with (
|
||||||
|
patch("homeassistant.components.backup.is_hassio", return_value=with_hassio),
|
||||||
|
patch(
|
||||||
|
"homeassistant.components.backup.backup.is_hassio", return_value=with_hassio
|
||||||
|
),
|
||||||
|
):
|
||||||
remote_agents = remote_agents or []
|
remote_agents = remote_agents or []
|
||||||
platform = Mock(
|
platform = Mock(
|
||||||
async_get_backup_agents=AsyncMock(
|
async_get_backup_agents=AsyncMock(
|
||||||
@@ -129,6 +134,7 @@ async def setup_backup_integration(
|
|||||||
assert await async_setup_component(hass, TEST_DOMAIN, {})
|
assert await async_setup_component(hass, TEST_DOMAIN, {})
|
||||||
|
|
||||||
result = await async_setup_component(hass, DOMAIN, configuration or {})
|
result = await async_setup_component(hass, DOMAIN, configuration or {})
|
||||||
|
await hass.async_block_till_done()
|
||||||
if with_hassio or not backups:
|
if with_hassio or not backups:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@@ -42,9 +42,6 @@
|
|||||||
'id': 1,
|
'id': 1,
|
||||||
'result': dict({
|
'result': dict({
|
||||||
'agents': list([
|
'agents': list([
|
||||||
dict({
|
|
||||||
'agent_id': 'backup.local',
|
|
||||||
}),
|
|
||||||
dict({
|
dict({
|
||||||
'agent_id': 'domain.test',
|
'agent_id': 'domain.test',
|
||||||
}),
|
}),
|
||||||
|
@@ -5,7 +5,7 @@ from unittest.mock import patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.backup.const import DOMAIN
|
from homeassistant.components.backup.const import DATA_MANAGER, DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .common import setup_backup_integration
|
from .common import setup_backup_integration
|
||||||
@@ -21,6 +21,8 @@ async def test_setup_with_hassio(
|
|||||||
with_hassio=True,
|
with_hassio=True,
|
||||||
configuration={DOMAIN: {}},
|
configuration={DOMAIN: {}},
|
||||||
)
|
)
|
||||||
|
manager = hass.data[DATA_MANAGER]
|
||||||
|
assert not manager.backup_agents
|
||||||
assert (
|
assert (
|
||||||
"The backup integration is not supported on this installation method, please"
|
"The backup integration is not supported on this installation method, please"
|
||||||
" remove it from your configuration"
|
" remove it from your configuration"
|
||||||
|
Reference in New Issue
Block a user