mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 07:06:30 +00:00
Avoid test failure by not checking exact size of backup (#5594)
* Avoid test failure by not checking exact size of backup This is a workaround for the fact that the backup size is not exactly the same every time. This is due to the fact that the inner gziped tar file can vary in size due to difference in json file (key order) and potentially also different field values (UUID, backup slug). It seems that sorting the keys makes the actual difference today, but this has runtime overhead and might not catch all cases. Simply check if size property is there and a number bigger than 0 instead. * Fix pytest
This commit is contained in:
parent
05b648629f
commit
28a87db515
@ -1035,12 +1035,13 @@ 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
|
||||
@ -1048,12 +1049,8 @@ async def test_protected_backup(
|
||||
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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user