@@ -137,7 +137,7 @@ async def test_backup_to_location(
137
137
await coresys .mounts .create_mount (mount )
138
138
coresys .mounts .default_backup_mount = mount
139
139
140
- coresys .core .state = CoreState .RUNNING
140
+ await coresys .core .set_state ( CoreState .RUNNING )
141
141
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
142
142
resp = await api_client .post (
143
143
"/backups/new/full" ,
@@ -178,7 +178,7 @@ async def test_backup_to_default(api_client: TestClient, coresys: CoreSys):
178
178
await coresys .mounts .create_mount (mount )
179
179
coresys .mounts .default_backup_mount = mount
180
180
181
- coresys .core .state = CoreState .RUNNING
181
+ await coresys .core .set_state ( CoreState .RUNNING )
182
182
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
183
183
resp = await api_client .post (
184
184
"/backups/new/full" ,
@@ -196,7 +196,7 @@ async def test_api_freeze_thaw(
196
196
api_client : TestClient , coresys : CoreSys , ha_ws_client : AsyncMock
197
197
):
198
198
"""Test manual freeze and thaw for external backup via API."""
199
- coresys .core .state = CoreState .RUNNING
199
+ await coresys .core .set_state ( CoreState .RUNNING )
200
200
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
201
201
ha_ws_client .ha_version = AwesomeVersion ("2022.1.0" )
202
202
@@ -230,7 +230,7 @@ async def test_api_backup_exclude_database(
230
230
exclude_db_setting : bool ,
231
231
):
232
232
"""Test backups exclude the database when specified."""
233
- coresys .core .state = CoreState .RUNNING
233
+ await coresys .core .set_state ( CoreState .RUNNING )
234
234
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
235
235
coresys .homeassistant .version = AwesomeVersion ("2023.09.0" )
236
236
coresys .homeassistant .backups_exclude_database = exclude_db_setting
@@ -278,7 +278,7 @@ async def test_api_backup_restore_background(
278
278
tmp_supervisor_data : Path ,
279
279
):
280
280
"""Test background option on backup/restore APIs."""
281
- coresys .core .state = CoreState .RUNNING
281
+ await coresys .core .set_state ( CoreState .RUNNING )
282
282
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
283
283
coresys .homeassistant .version = AwesomeVersion ("2023.09.0" )
284
284
(tmp_supervisor_data / "addons/local" ).mkdir (parents = True )
@@ -364,7 +364,7 @@ async def test_api_backup_errors(
364
364
tmp_supervisor_data : Path ,
365
365
):
366
366
"""Test error reporting in backup job."""
367
- coresys .core .state = CoreState .RUNNING
367
+ await coresys .core .set_state ( CoreState .RUNNING )
368
368
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
369
369
coresys .homeassistant .version = AwesomeVersion ("2023.09.0" )
370
370
(tmp_supervisor_data / "addons/local" ).mkdir (parents = True )
@@ -435,15 +435,15 @@ async def test_api_backup_errors(
435
435
436
436
async def test_backup_immediate_errors (api_client : TestClient , coresys : CoreSys ):
437
437
"""Test backup errors that return immediately even in background mode."""
438
- coresys .core .state = CoreState .FREEZE
438
+ await coresys .core .set_state ( CoreState .FREEZE )
439
439
resp = await api_client .post (
440
440
"/backups/new/full" ,
441
441
json = {"name" : "Test" , "background" : True },
442
442
)
443
443
assert resp .status == 400
444
444
assert "freeze" in (await resp .json ())["message" ]
445
445
446
- coresys .core .state = CoreState .RUNNING
446
+ await coresys .core .set_state ( CoreState .RUNNING )
447
447
coresys .hardware .disk .get_disk_free_space = lambda x : 0.5
448
448
resp = await api_client .post (
449
449
"/backups/new/partial" ,
@@ -460,7 +460,7 @@ async def test_restore_immediate_errors(
460
460
mock_partial_backup : Backup ,
461
461
):
462
462
"""Test restore errors that return immediately even in background mode."""
463
- coresys .core .state = CoreState .RUNNING
463
+ await coresys .core .set_state ( CoreState .RUNNING )
464
464
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
465
465
466
466
resp = await api_client .post (
@@ -634,7 +634,7 @@ async def test_backup_to_multiple_locations(
634
634
inputs : dict [str , Any ],
635
635
):
636
636
"""Test making a backup to multiple locations."""
637
- coresys .core .state = CoreState .RUNNING
637
+ await coresys .core .set_state ( CoreState .RUNNING )
638
638
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
639
639
640
640
resp = await api_client .post (
@@ -669,7 +669,7 @@ async def test_backup_with_extras(
669
669
inputs : dict [str , Any ],
670
670
):
671
671
"""Test backup including extra metdata."""
672
- coresys .core .state = CoreState .RUNNING
672
+ await coresys .core .set_state ( CoreState .RUNNING )
673
673
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
674
674
675
675
resp = await api_client .post (
@@ -909,7 +909,7 @@ async def test_partial_backup_all_addons(
909
909
install_addon_ssh : Addon ,
910
910
):
911
911
"""Test backup including extra metdata."""
912
- coresys .core .state = CoreState .RUNNING
912
+ await coresys .core .set_state ( CoreState .RUNNING )
913
913
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
914
914
915
915
with patch .object (Backup , "store_addons" ) as store_addons :
@@ -928,7 +928,7 @@ async def test_restore_backup_from_location(
928
928
local_location : str | None ,
929
929
):
930
930
"""Test restoring a backup from a specific location."""
931
- coresys .core .state = CoreState .RUNNING
931
+ await coresys .core .set_state ( CoreState .RUNNING )
932
932
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
933
933
934
934
# Make a backup and a file to test with
@@ -1000,7 +1000,7 @@ async def test_restore_backup_unencrypted_after_encrypted(
1000
1000
# We punt the ball on this one for this PR since this is a rare edge case.
1001
1001
backup .restore_dockerconfig = MagicMock ()
1002
1002
1003
- coresys .core .state = CoreState .RUNNING
1003
+ await coresys .core .set_state ( CoreState .RUNNING )
1004
1004
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
1005
1005
1006
1006
# Restore encrypted backup
@@ -1050,7 +1050,7 @@ async def test_restore_homeassistant_adds_env(
1050
1050
):
1051
1051
"""Test restoring home assistant from backup adds env to container."""
1052
1052
event = asyncio .Event ()
1053
- coresys .core .state = CoreState .RUNNING
1053
+ await coresys .core .set_state ( CoreState .RUNNING )
1054
1054
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
1055
1055
coresys .homeassistant .version = AwesomeVersion ("2025.1.0" )
1056
1056
backup = await coresys .backups .do_backup_full ()
@@ -1134,7 +1134,7 @@ async def test_protected_backup(
1134
1134
api_client : TestClient , coresys : CoreSys , backup_type : str , options : dict [str , Any ]
1135
1135
):
1136
1136
"""Test creating a protected backup."""
1137
- coresys .core .state = CoreState .RUNNING
1137
+ await coresys .core .set_state ( CoreState .RUNNING )
1138
1138
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
1139
1139
1140
1140
resp = await api_client .post (
@@ -1246,7 +1246,7 @@ async def test_missing_file_removes_location_from_cache(
1246
1246
backup_file : str ,
1247
1247
):
1248
1248
"""Test finding a missing file removes the location from cache."""
1249
- coresys .core .state = CoreState .RUNNING
1249
+ await coresys .core .set_state ( CoreState .RUNNING )
1250
1250
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
1251
1251
1252
1252
backup_file = get_fixture_path (backup_file )
@@ -1305,7 +1305,7 @@ async def test_missing_file_removes_backup_from_cache(
1305
1305
backup_file : str ,
1306
1306
):
1307
1307
"""Test finding a missing file removes the backup from cache if its the only one."""
1308
- coresys .core .state = CoreState .RUNNING
1308
+ await coresys .core .set_state ( CoreState .RUNNING )
1309
1309
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
1310
1310
1311
1311
backup_file = get_fixture_path (backup_file )
@@ -1331,7 +1331,7 @@ async def test_immediate_list_after_missing_file_restore(
1331
1331
api_client : TestClient , coresys : CoreSys
1332
1332
):
1333
1333
"""Test race with reload for missing file on restore does not error."""
1334
- coresys .core .state = CoreState .RUNNING
1334
+ await coresys .core .set_state ( CoreState .RUNNING )
1335
1335
coresys .hardware .disk .get_disk_free_space = lambda x : 5000
1336
1336
1337
1337
backup_file = get_fixture_path ("backup_example.tar" )
0 commit comments