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