mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Merge pull request #135 from lrnselfreliance/feature/testing-status
Adding minimum tests for status functions and page.
This commit is contained in:
commit
1c7d01f2fd
3 changed files with 42 additions and 1 deletions
|
|
@ -6,7 +6,7 @@ import subprocess
|
|||
from dataclasses import dataclass
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
from typing import List
|
||||
|
||||
from wrolpi.common import logger
|
||||
|
||||
|
|
|
|||
|
|
@ -297,3 +297,12 @@ def test_clear_downloads(test_session, test_client, test_config, test_download_m
|
|||
|
||||
# Failed once-downloads will not be downloaded again.
|
||||
assert DOWNLOAD_MANAGER_CONFIG.skip_urls == ['https://example.com/5', ]
|
||||
|
||||
|
||||
def test_get_status(test_client):
|
||||
"""Get the server status information."""
|
||||
request, response = test_client.get('/api/status')
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
assert 'cpu_info' in response.json and isinstance(response.json['cpu_info'], dict)
|
||||
assert 'load' in response.json and isinstance(response.json['load'], dict)
|
||||
assert 'drives' in response.json and isinstance(response.json['drives'], list)
|
||||
|
|
|
|||
32
wrolpi/test/test_status.py
Normal file
32
wrolpi/test/test_status.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
from wrolpi import status
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_load():
|
||||
"""Minimum laod testing because this will fail in docker, etc."""
|
||||
load = await status.get_load()
|
||||
assert isinstance(load, status.SystemLoad)
|
||||
assert load.minute_1 is not None and isinstance(load.minute_1, Decimal)
|
||||
assert load.minute_5 is not None and isinstance(load.minute_5, Decimal)
|
||||
assert load.minute_15 is not None and isinstance(load.minute_15, Decimal)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_cpu_info():
|
||||
"""Minimum CPU info testing because this will fail in docker, etc."""
|
||||
info = await status.get_cpu_info()
|
||||
assert isinstance(info, status.CPUInfo)
|
||||
assert isinstance(info.percent, int)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_drives_info():
|
||||
"""Minimum drives info testing because this will fail in docker, etc."""
|
||||
info = await status.get_drives_info()
|
||||
assert isinstance(info, list)
|
||||
assert len(info) >= 1
|
||||
assert isinstance(info[0], status.DriveInfo)
|
||||
Loading…
Add table
Add a link
Reference in a new issue