| 1 |
import importlib |
| 2 |
import os |
| 3 |
|
| 4 |
import pytest |
| 5 |
|
| 6 |
from celery.utils.sysinfo import df, load_average |
| 7 |
|
| 8 |
try: |
| 9 |
posix = importlib.import_module('posix') |
| 10 |
except Exception: |
| 11 |
posix = None |
| 12 |
|
| 13 |
|
| 14 |
@pytest.mark.skipif( |
| 15 |
not hasattr(os, 'getloadavg'), |
| 16 |
reason='Function os.getloadavg is not defined' |
| 17 |
) |
| 18 |
def test_load_average(patching): |
| 19 |
getloadavg = patching('os.getloadavg') |
| 20 |
getloadavg.return_value = 0.54736328125, 0.6357421875, 0.69921875 |
| 21 |
l = load_average() |
| 22 |
assert l |
| 23 |
assert l == (0.55, 0.64, 0.7) |
| 24 |
|
| 25 |
|
| 26 |
@pytest.mark.skipif( |
| 27 |
not hasattr(posix, 'statvfs_result'), |
| 28 |
reason='Function posix.statvfs_result is not defined' |
| 29 |
) |
| 30 |
def test_df(): |
| 31 |
x = df('/') |
| 32 |
assert x.total_blocks |
| 33 |
assert x.available |
| 34 |
assert x.capacity |
| 35 |
assert x.stat |