forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π Fix flaky
test_disk_usage
(ITISFoundation#5364)
Co-authored-by: Andrei Neagu <[email protected]>
- Loading branch information
Showing
1 changed file
with
22 additions
and
3 deletions.
There are no files selected for viewing
25 changes: 22 additions & 3 deletions
25
packages/models-library/tests/test_api_schemas_dynamic_sidecar_telemetry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
import psutil | ||
import pytest | ||
from models_library.api_schemas_dynamic_sidecar.telemetry import DiskUsage | ||
from psutil._common import sdiskusage | ||
|
||
|
||
def test_disk_usage(): | ||
ps_util_disk_usage = psutil.disk_usage("/") | ||
def _assert_same_value(ps_util_disk_usage: sdiskusage) -> None: | ||
disk_usage = DiskUsage.from_ps_util_disk_usage(ps_util_disk_usage) | ||
assert disk_usage.used == ps_util_disk_usage.used | ||
assert disk_usage.free == ps_util_disk_usage.free | ||
assert round(disk_usage.used_percent, 1) == round(ps_util_disk_usage.percent, 1) | ||
assert disk_usage.used_percent == pytest.approx(ps_util_disk_usage.percent, abs=1e3) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"ps_util_disk_usage", | ||
[ | ||
sdiskusage(total=77851254784, used=58336940032, free=19497537536, percent=74.9), | ||
sdiskusage(total=77851254784, used=58573619200, free=19260858368, percent=75.3), | ||
sdiskusage(total=77851254784, used=58573529088, free=19260948480, percent=75.3), | ||
sdiskusage(total=77851254784, used=58573664256, free=19260813312, percent=75.3), | ||
], | ||
) | ||
def test_disk_usage_regression_cases(ps_util_disk_usage: sdiskusage): | ||
_assert_same_value(ps_util_disk_usage) | ||
|
||
|
||
def test_disk_usage(): | ||
ps_util_disk_usage = psutil.disk_usage("/") | ||
_assert_same_value(ps_util_disk_usage) |