Minor adjustments of hassio backup tests (#137324)

This commit is contained in:
Erik Montnemery 2025-02-04 14:19:48 +01:00 committed by GitHub
parent a4f0194786
commit 345cbc62a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -106,7 +106,7 @@ TEST_BACKUP_2 = supervisor_backups.Backup(
compressed=False, compressed=False,
content=supervisor_backups.BackupContent( content=supervisor_backups.BackupContent(
addons=["ssl"], addons=["ssl"],
folders=["share"], folders=[supervisor_backups.Folder.SHARE],
homeassistant=False, homeassistant=False,
), ),
date=datetime.fromisoformat("1970-01-01T00:00:00Z"), date=datetime.fromisoformat("1970-01-01T00:00:00Z"),
@ -136,7 +136,7 @@ TEST_BACKUP_DETAILS_2 = supervisor_backups.BackupComplete(
compressed=TEST_BACKUP_2.compressed, compressed=TEST_BACKUP_2.compressed,
date=TEST_BACKUP_2.date, date=TEST_BACKUP_2.date,
extra=None, extra=None,
folders=["share"], folders=[supervisor_backups.Folder.SHARE],
homeassistant_exclude_database=False, homeassistant_exclude_database=False,
homeassistant=None, homeassistant=None,
location=TEST_BACKUP_2.location, location=TEST_BACKUP_2.location,
@ -156,7 +156,7 @@ TEST_BACKUP_3 = supervisor_backups.Backup(
compressed=False, compressed=False,
content=supervisor_backups.BackupContent( content=supervisor_backups.BackupContent(
addons=["ssl"], addons=["ssl"],
folders=["share"], folders=[supervisor_backups.Folder.SHARE],
homeassistant=True, homeassistant=True,
), ),
date=datetime.fromisoformat("1970-01-01T00:00:00Z"), date=datetime.fromisoformat("1970-01-01T00:00:00Z"),
@ -186,7 +186,7 @@ TEST_BACKUP_DETAILS_3 = supervisor_backups.BackupComplete(
compressed=TEST_BACKUP_3.compressed, compressed=TEST_BACKUP_3.compressed,
date=TEST_BACKUP_3.date, date=TEST_BACKUP_3.date,
extra=None, extra=None,
folders=["share"], folders=[supervisor_backups.Folder.SHARE],
homeassistant_exclude_database=False, homeassistant_exclude_database=False,
homeassistant=None, homeassistant=None,
location=TEST_BACKUP_3.location, location=TEST_BACKUP_3.location,
@ -207,7 +207,7 @@ TEST_BACKUP_4 = supervisor_backups.Backup(
compressed=False, compressed=False,
content=supervisor_backups.BackupContent( content=supervisor_backups.BackupContent(
addons=["ssl"], addons=["ssl"],
folders=["share"], folders=[supervisor_backups.Folder.SHARE],
homeassistant=True, homeassistant=True,
), ),
date=datetime.fromisoformat("1970-01-01T00:00:00Z"), date=datetime.fromisoformat("1970-01-01T00:00:00Z"),
@ -234,23 +234,23 @@ TEST_BACKUP_DETAILS_4 = supervisor_backups.BackupComplete(
version="9.14.0", version="9.14.0",
) )
], ],
compressed=TEST_BACKUP.compressed, compressed=TEST_BACKUP_4.compressed,
date=TEST_BACKUP.date, date=TEST_BACKUP_4.date,
extra=None, extra=None,
folders=["share"], folders=[supervisor_backups.Folder.SHARE],
homeassistant_exclude_database=True, homeassistant_exclude_database=True,
homeassistant="2024.12.0", homeassistant="2024.12.0",
location=TEST_BACKUP.location, location=TEST_BACKUP_4.location,
location_attributes=TEST_BACKUP.location_attributes, location_attributes=TEST_BACKUP_4.location_attributes,
locations=TEST_BACKUP.locations, locations=TEST_BACKUP_4.locations,
name=TEST_BACKUP.name, name=TEST_BACKUP_4.name,
protected=TEST_BACKUP.protected, protected=TEST_BACKUP_4.protected,
repositories=[], repositories=[],
size=TEST_BACKUP.size, size=TEST_BACKUP_4.size,
size_bytes=TEST_BACKUP.size_bytes, size_bytes=TEST_BACKUP_4.size_bytes,
slug=TEST_BACKUP.slug, slug=TEST_BACKUP_4.slug,
supervisor_version="2024.11.2", supervisor_version="2024.11.2",
type=TEST_BACKUP.type, type=TEST_BACKUP_4.type,
) )
TEST_BACKUP_5 = supervisor_backups.Backup( TEST_BACKUP_5 = supervisor_backups.Backup(
@ -364,7 +364,7 @@ async def hassio_enabled(
@pytest.fixture @pytest.fixture
async def setup_integration( async def setup_backup_integration(
hass: HomeAssistant, hassio_enabled: None, supervisor_client: AsyncMock hass: HomeAssistant, hassio_enabled: None, supervisor_client: AsyncMock
) -> None: ) -> None:
"""Set up Backup integration.""" """Set up Backup integration."""
@ -494,7 +494,7 @@ async def test_agent_info(
} }
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
@pytest.mark.parametrize( @pytest.mark.parametrize(
("backup", "backup_details", "expected_response"), ("backup", "backup_details", "expected_response"),
[ [
@ -558,7 +558,7 @@ async def test_agent_list_backups(
assert response["result"]["backups"] == [expected_response] assert response["result"]["backups"] == [expected_response]
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_agent_download( async def test_agent_download(
hass: HomeAssistant, hass: HomeAssistant,
hass_client: ClientSessionGenerator, hass_client: ClientSessionGenerator,
@ -582,7 +582,7 @@ async def test_agent_download(
) )
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_agent_download_unavailable_backup( async def test_agent_download_unavailable_backup(
hass: HomeAssistant, hass: HomeAssistant,
hass_client: ClientSessionGenerator, hass_client: ClientSessionGenerator,
@ -601,7 +601,7 @@ async def test_agent_download_unavailable_backup(
assert resp.status == 404 assert resp.status == 404
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_agent_upload( async def test_agent_upload(
hass: HomeAssistant, hass: HomeAssistant,
hass_client: ClientSessionGenerator, hass_client: ClientSessionGenerator,
@ -650,7 +650,7 @@ async def test_agent_upload(
supervisor_client.backups.remove_backup.assert_not_called() supervisor_client.backups.remove_backup.assert_not_called()
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_agent_get_backup( async def test_agent_get_backup(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -691,7 +691,7 @@ async def test_agent_get_backup(
supervisor_client.backups.backup_info.assert_called_once_with(backup_id) supervisor_client.backups.backup_info.assert_called_once_with(backup_id)
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
@pytest.mark.parametrize( @pytest.mark.parametrize(
("backup_info_side_effect", "expected_response"), ("backup_info_side_effect", "expected_response"),
[ [
@ -735,7 +735,7 @@ async def test_agent_get_backup_with_error(
supervisor_client.backups.backup_info.assert_called_once_with(backup_id) supervisor_client.backups.backup_info.assert_called_once_with(backup_id)
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_agent_delete_backup( async def test_agent_delete_backup(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -760,7 +760,7 @@ async def test_agent_delete_backup(
) )
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
@pytest.mark.parametrize( @pytest.mark.parametrize(
("remove_side_effect", "expected_response"), ("remove_side_effect", "expected_response"),
[ [
@ -806,7 +806,7 @@ async def test_agent_delete_with_error(
) )
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
@pytest.mark.parametrize( @pytest.mark.parametrize(
("event_data", "mount_info_calls"), ("event_data", "mount_info_calls"),
[ [
@ -887,7 +887,7 @@ DEFAULT_BACKUP_OPTIONS = supervisor_backups.PartialBackupOptions(
) )
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
@pytest.mark.parametrize( @pytest.mark.parametrize(
("extra_generate_options", "expected_supervisor_options"), ("extra_generate_options", "expected_supervisor_options"),
[ [
@ -1002,7 +1002,7 @@ async def test_reader_writer_create(
assert response["event"] == {"manager_state": "idle"} assert response["event"] == {"manager_state": "idle"}
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_reader_writer_create_report_progress( async def test_reader_writer_create_report_progress(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -1109,7 +1109,7 @@ async def test_reader_writer_create_report_progress(
assert response["event"] == {"manager_state": "idle"} assert response["event"] == {"manager_state": "idle"}
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_reader_writer_create_job_done( async def test_reader_writer_create_job_done(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -1400,7 +1400,7 @@ async def test_reader_writer_create_per_agent_encryption(
assert response["event"] == {"manager_state": "idle"} assert response["event"] == {"manager_state": "idle"}
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
@pytest.mark.parametrize( @pytest.mark.parametrize(
("side_effect", "error_code", "error_message", "expected_reason"), ("side_effect", "error_code", "error_message", "expected_reason"),
[ [
@ -1495,7 +1495,7 @@ async def test_reader_writer_create_partial_backup_error(
}, },
], ],
) )
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_reader_writer_create_missing_reference_error( async def test_reader_writer_create_missing_reference_error(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -1554,7 +1554,7 @@ async def test_reader_writer_create_missing_reference_error(
assert response["event"] == {"manager_state": "idle"} assert response["event"] == {"manager_state": "idle"}
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
@pytest.mark.parametrize("exception", [SupervisorError("Boom!"), Exception("Boom!")]) @pytest.mark.parametrize("exception", [SupervisorError("Boom!"), Exception("Boom!")])
@pytest.mark.parametrize( @pytest.mark.parametrize(
("method", "download_call_count", "remove_call_count"), ("method", "download_call_count", "remove_call_count"),
@ -1648,7 +1648,7 @@ async def test_reader_writer_create_download_remove_error(
assert response["event"] == {"manager_state": "idle"} assert response["event"] == {"manager_state": "idle"}
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
@pytest.mark.parametrize("exception", [SupervisorError("Boom!"), Exception("Boom!")]) @pytest.mark.parametrize("exception", [SupervisorError("Boom!"), Exception("Boom!")])
async def test_reader_writer_create_info_error( async def test_reader_writer_create_info_error(
hass: HomeAssistant, hass: HomeAssistant,
@ -1725,7 +1725,7 @@ async def test_reader_writer_create_info_error(
assert response["event"] == {"manager_state": "idle"} assert response["event"] == {"manager_state": "idle"}
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_reader_writer_create_remote_backup( async def test_reader_writer_create_remote_backup(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -1809,7 +1809,7 @@ async def test_reader_writer_create_remote_backup(
) )
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
@pytest.mark.parametrize( @pytest.mark.parametrize(
("extra_generate_options", "expected_error"), ("extra_generate_options", "expected_error"),
[ [
@ -1879,7 +1879,7 @@ async def test_reader_writer_create_wrong_parameters(
supervisor_client.backups.partial_backup.assert_not_called() supervisor_client.backups.partial_backup.assert_not_called()
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_agent_receive_remote_backup( async def test_agent_receive_remote_backup(
hass: HomeAssistant, hass: HomeAssistant,
hass_client: ClientSessionGenerator, hass_client: ClientSessionGenerator,
@ -1955,7 +1955,7 @@ async def test_agent_receive_remote_backup(
), ),
], ],
) )
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_reader_writer_restore( async def test_reader_writer_restore(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -2022,7 +2022,7 @@ async def test_reader_writer_restore(
assert response["result"] is None assert response["result"] is None
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_reader_writer_restore_report_progress( async def test_reader_writer_restore_report_progress(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -2136,7 +2136,7 @@ async def test_reader_writer_restore_report_progress(
), ),
], ],
) )
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_reader_writer_restore_error( async def test_reader_writer_restore_error(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -2197,7 +2197,7 @@ async def test_reader_writer_restore_error(
assert response["error"]["code"] == expected_error_code assert response["error"]["code"] == expected_error_code
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_reader_writer_restore_late_error( async def test_reader_writer_restore_late_error(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
@ -2311,7 +2311,7 @@ async def test_reader_writer_restore_late_error(
), ),
], ],
) )
@pytest.mark.usefixtures("hassio_client", "setup_integration") @pytest.mark.usefixtures("hassio_client", "setup_backup_integration")
async def test_reader_writer_restore_wrong_parameters( async def test_reader_writer_restore_wrong_parameters(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,