mirror of
https://github.com/nicolargo/glances.git
synced 2026-09-16 23:28:24 -04:00
Correct sensors unit test
This commit is contained in:
1 parent
635d3a04fa
commit
fca88aaa0b
2 files changed
+23
-1
No files matched your search
@@ -290,7 +290,8 @@ class SensorsPlugin(GlancesPluginModel):
|
||||
)
|
||||
else:
|
||||
if (
|
||||
args.fahrenheit
|
||||
args
|
||||
and args.fahrenheit
|
||||
and i['type'] != sensors_definition.get('battery').get('type')
|
||||
and i['type'] != sensors_definition.get('fan_speed').get('type')
|
||||
):
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"""Tests for the Sensors plugin."""
|
||||
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -179,6 +180,7 @@ class TestSensorsPluginMsgCurse:
|
||||
def test_msg_curse_returns_list(self, sensors_plugin):
|
||||
"""Test that msg_curse returns a list."""
|
||||
sensors_plugin.update()
|
||||
sensors_plugin.update_views()
|
||||
msg = sensors_plugin.msg_curse(max_width=80)
|
||||
assert isinstance(msg, list)
|
||||
|
||||
@@ -188,6 +190,25 @@ class TestSensorsPluginMsgCurse:
|
||||
msg = sensors_plugin.msg_curse()
|
||||
assert isinstance(msg, list)
|
||||
|
||||
def test_msg_curse_without_args(self, sensors_plugin):
|
||||
"""Test that msg_curse does not crash when args is None."""
|
||||
stats = [
|
||||
{
|
||||
'label': 'CPU',
|
||||
'unit': 'C',
|
||||
'value': 42,
|
||||
'warning': 60,
|
||||
'critical': 80,
|
||||
'type': 'temperature_core',
|
||||
'key': 'label',
|
||||
}
|
||||
]
|
||||
with patch.object(sensors_plugin, 'stats', stats):
|
||||
sensors_plugin.update_views()
|
||||
msg = sensors_plugin.msg_curse(max_width=80)
|
||||
assert isinstance(msg, list)
|
||||
assert any('42C' in m['msg'] for m in msg)
|
||||
|
||||
|
||||
class TestSensorsPluginExport:
|
||||
"""Test Sensors plugin export functionality."""
|
||||
|
||||
Reference in new issue
Block a user