Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid test failure by not checking exact size of backup #5594

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions tests/api/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,25 +1035,22 @@ async def test_protected_backup(
assert body["data"]["backups"][0]["location"] is None
assert body["data"]["backups"][0]["locations"] == [None]
assert body["data"]["backups"][0]["protected"] is True
assert body["data"]["backups"][0]["location_attributes"] == {
".local": {
"protected": True,
"size_bytes": 10240,
}
}
assert (
body["data"]["backups"][0]["location_attributes"][".local"]["protected"] is True
)
# NOTE: It is not safe to check size exactly here, as order of keys in
# `homeassistant.json` and potentially other random data (e.g. isntance UUID,
# backup slug) does change the size of the backup (due to gzip).
assert body["data"]["backups"][0]["location_attributes"][".local"]["size_bytes"] > 0

resp = await api_client.get(f"/backups/{slug}/info")
assert resp.status == 200
body = await resp.json()
assert body["data"]["location"] is None
assert body["data"]["locations"] == [None]
assert body["data"]["protected"] is True
assert body["data"]["location_attributes"] == {
".local": {
"protected": True,
"size_bytes": 10240,
}
}
assert body["data"]["location_attributes"][".local"]["protected"] is True
assert body["data"]["location_attributes"][".local"]["size_bytes"] > 0


@pytest.mark.usefixtures(
Expand Down