mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Improve backup store in tests (#135798)
This commit is contained in:
parent
ef34a33a7b
commit
1fee0a5aa2
@ -227,7 +227,7 @@
|
|||||||
'type': 'result',
|
'type': 'result',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_config_info[None]
|
# name: test_config_info[storage_data0]
|
||||||
dict({
|
dict({
|
||||||
'id': 1,
|
'id': 1,
|
||||||
'result': dict({
|
'result': dict({
|
||||||
|
@ -848,11 +848,6 @@ async def test_async_initiate_backup_non_agent_upload_error(
|
|||||||
exception: Exception,
|
exception: Exception,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test an unknown or writer upload error during backup generation."""
|
"""Test an unknown or writer upload error during backup generation."""
|
||||||
hass_storage[DOMAIN] = {
|
|
||||||
"data": {},
|
|
||||||
"key": DOMAIN,
|
|
||||||
"version": 1,
|
|
||||||
}
|
|
||||||
agent_ids = [LOCAL_AGENT_ID, "test.remote"]
|
agent_ids = [LOCAL_AGENT_ID, "test.remote"]
|
||||||
local_agent = local_backup_platform.CoreLocalBackupAgent(hass)
|
local_agent = local_backup_platform.CoreLocalBackupAgent(hass)
|
||||||
remote_agent = BackupAgentTest("remote", backups=[])
|
remote_agent = BackupAgentTest("remote", backups=[])
|
||||||
@ -944,7 +939,7 @@ async def test_async_initiate_backup_non_agent_upload_error(
|
|||||||
result = await ws_client.receive_json()
|
result = await ws_client.receive_json()
|
||||||
assert result["event"] == {"manager_state": BackupManagerState.IDLE}
|
assert result["event"] == {"manager_state": BackupManagerState.IDLE}
|
||||||
|
|
||||||
assert not hass_storage[DOMAIN]["data"]
|
assert DOMAIN not in hass_storage
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("mock_backup_generation")
|
@pytest.mark.usefixtures("mock_backup_generation")
|
||||||
@ -1724,11 +1719,6 @@ async def test_receive_backup_non_agent_upload_error(
|
|||||||
exception: Exception,
|
exception: Exception,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test non agent upload error during backup receive."""
|
"""Test non agent upload error during backup receive."""
|
||||||
hass_storage[DOMAIN] = {
|
|
||||||
"data": {},
|
|
||||||
"key": DOMAIN,
|
|
||||||
"version": 1,
|
|
||||||
}
|
|
||||||
local_agent = local_backup_platform.CoreLocalBackupAgent(hass)
|
local_agent = local_backup_platform.CoreLocalBackupAgent(hass)
|
||||||
remote_agent = BackupAgentTest("remote", backups=[])
|
remote_agent = BackupAgentTest("remote", backups=[])
|
||||||
|
|
||||||
@ -1814,7 +1804,7 @@ async def test_receive_backup_non_agent_upload_error(
|
|||||||
result = await ws_client.receive_json()
|
result = await ws_client.receive_json()
|
||||||
assert result["event"] == {"manager_state": BackupManagerState.IDLE}
|
assert result["event"] == {"manager_state": BackupManagerState.IDLE}
|
||||||
|
|
||||||
assert not hass_storage[DOMAIN]["data"]
|
assert DOMAIN not in hass_storage
|
||||||
assert resp.status == 500
|
assert resp.status == 500
|
||||||
assert open_mock.call_count == 1
|
assert open_mock.call_count == 1
|
||||||
assert move_mock.call_count == 0
|
assert move_mock.call_count == 0
|
||||||
|
@ -906,95 +906,125 @@ async def test_agents_info(
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"storage_data",
|
"storage_data",
|
||||||
[
|
[
|
||||||
None,
|
{},
|
||||||
{
|
{
|
||||||
"backups": {},
|
"backup": {
|
||||||
"config": {
|
"data": {
|
||||||
"create_backup": {
|
"backups": {},
|
||||||
"agent_ids": ["test-agent"],
|
"config": {
|
||||||
"include_addons": ["test-addon"],
|
"create_backup": {
|
||||||
"include_all_addons": True,
|
"agent_ids": ["test-agent"],
|
||||||
"include_database": True,
|
"include_addons": ["test-addon"],
|
||||||
"include_folders": ["media"],
|
"include_all_addons": True,
|
||||||
"name": "test-name",
|
"include_database": True,
|
||||||
"password": "test-password",
|
"include_folders": ["media"],
|
||||||
|
"name": "test-name",
|
||||||
|
"password": "test-password",
|
||||||
|
},
|
||||||
|
"retention": {"copies": 3, "days": 7},
|
||||||
|
"last_attempted_automatic_backup": "2024-10-26T04:45:00+01:00",
|
||||||
|
"last_completed_automatic_backup": "2024-10-26T04:45:00+01:00",
|
||||||
|
"schedule": {"state": "daily"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"retention": {"copies": 3, "days": 7},
|
"key": DOMAIN,
|
||||||
"last_attempted_automatic_backup": "2024-10-26T04:45:00+01:00",
|
"version": 1,
|
||||||
"last_completed_automatic_backup": "2024-10-26T04:45:00+01:00",
|
|
||||||
"schedule": {"state": "daily"},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"backups": {},
|
"backup": {
|
||||||
"config": {
|
"data": {
|
||||||
"create_backup": {
|
"backups": {},
|
||||||
"agent_ids": ["test-agent"],
|
"config": {
|
||||||
"include_addons": None,
|
"create_backup": {
|
||||||
"include_all_addons": False,
|
"agent_ids": ["test-agent"],
|
||||||
"include_database": False,
|
"include_addons": None,
|
||||||
"include_folders": None,
|
"include_all_addons": False,
|
||||||
"name": None,
|
"include_database": False,
|
||||||
"password": None,
|
"include_folders": None,
|
||||||
|
"name": None,
|
||||||
|
"password": None,
|
||||||
|
},
|
||||||
|
"retention": {"copies": 3, "days": None},
|
||||||
|
"last_attempted_automatic_backup": None,
|
||||||
|
"last_completed_automatic_backup": None,
|
||||||
|
"schedule": {"state": "never"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"retention": {"copies": 3, "days": None},
|
"key": DOMAIN,
|
||||||
"last_attempted_automatic_backup": None,
|
"version": 1,
|
||||||
"last_completed_automatic_backup": None,
|
|
||||||
"schedule": {"state": "never"},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"backups": {},
|
"backup": {
|
||||||
"config": {
|
"data": {
|
||||||
"create_backup": {
|
"backups": {},
|
||||||
"agent_ids": ["test-agent"],
|
"config": {
|
||||||
"include_addons": None,
|
"create_backup": {
|
||||||
"include_all_addons": False,
|
"agent_ids": ["test-agent"],
|
||||||
"include_database": False,
|
"include_addons": None,
|
||||||
"include_folders": None,
|
"include_all_addons": False,
|
||||||
"name": None,
|
"include_database": False,
|
||||||
"password": None,
|
"include_folders": None,
|
||||||
|
"name": None,
|
||||||
|
"password": None,
|
||||||
|
},
|
||||||
|
"retention": {"copies": None, "days": 7},
|
||||||
|
"last_attempted_automatic_backup": "2024-10-27T04:45:00+01:00",
|
||||||
|
"last_completed_automatic_backup": "2024-10-26T04:45:00+01:00",
|
||||||
|
"schedule": {"state": "never"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"retention": {"copies": None, "days": 7},
|
"key": DOMAIN,
|
||||||
"last_attempted_automatic_backup": "2024-10-27T04:45:00+01:00",
|
"version": 1,
|
||||||
"last_completed_automatic_backup": "2024-10-26T04:45:00+01:00",
|
|
||||||
"schedule": {"state": "never"},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"backups": {},
|
"backup": {
|
||||||
"config": {
|
"data": {
|
||||||
"create_backup": {
|
"backups": {},
|
||||||
"agent_ids": ["test-agent"],
|
"config": {
|
||||||
"include_addons": None,
|
"create_backup": {
|
||||||
"include_all_addons": False,
|
"agent_ids": ["test-agent"],
|
||||||
"include_database": False,
|
"include_addons": None,
|
||||||
"include_folders": None,
|
"include_all_addons": False,
|
||||||
"name": None,
|
"include_database": False,
|
||||||
"password": None,
|
"include_folders": None,
|
||||||
|
"name": None,
|
||||||
|
"password": None,
|
||||||
|
},
|
||||||
|
"retention": {"copies": None, "days": None},
|
||||||
|
"last_attempted_automatic_backup": None,
|
||||||
|
"last_completed_automatic_backup": None,
|
||||||
|
"schedule": {"state": "mon"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"retention": {"copies": None, "days": None},
|
"key": DOMAIN,
|
||||||
"last_attempted_automatic_backup": None,
|
"version": 1,
|
||||||
"last_completed_automatic_backup": None,
|
|
||||||
"schedule": {"state": "mon"},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"backups": {},
|
"backup": {
|
||||||
"config": {
|
"data": {
|
||||||
"create_backup": {
|
"backups": {},
|
||||||
"agent_ids": ["test-agent"],
|
"config": {
|
||||||
"include_addons": None,
|
"create_backup": {
|
||||||
"include_all_addons": False,
|
"agent_ids": ["test-agent"],
|
||||||
"include_database": False,
|
"include_addons": None,
|
||||||
"include_folders": None,
|
"include_all_addons": False,
|
||||||
"name": None,
|
"include_database": False,
|
||||||
"password": None,
|
"include_folders": None,
|
||||||
|
"name": None,
|
||||||
|
"password": None,
|
||||||
|
},
|
||||||
|
"retention": {"copies": None, "days": None},
|
||||||
|
"last_attempted_automatic_backup": None,
|
||||||
|
"last_completed_automatic_backup": None,
|
||||||
|
"schedule": {"state": "sat"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"retention": {"copies": None, "days": None},
|
"key": DOMAIN,
|
||||||
"last_attempted_automatic_backup": None,
|
"version": 1,
|
||||||
"last_completed_automatic_backup": None,
|
|
||||||
"schedule": {"state": "sat"},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -1007,11 +1037,7 @@ async def test_config_info(
|
|||||||
storage_data: dict[str, Any] | None,
|
storage_data: dict[str, Any] | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting backup config info."""
|
"""Test getting backup config info."""
|
||||||
hass_storage[DOMAIN] = {
|
hass_storage.update(storage_data)
|
||||||
"data": storage_data,
|
|
||||||
"key": DOMAIN,
|
|
||||||
"version": 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
await setup_backup_integration(hass)
|
await setup_backup_integration(hass)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user