mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
adding sensors unit test case
This commit is contained in:
parent
e0b2a73eb4
commit
1fb48a31a8
1 changed files with 43 additions and 0 deletions
43
tests/unit/modules/sensors_test.py
Normal file
43
tests/unit/modules/sensors_test.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from salttesting import skipIf, TestCase
|
||||
from salttesting.mock import (
|
||||
NO_MOCK,
|
||||
NO_MOCK_REASON,
|
||||
MagicMock,
|
||||
patch)
|
||||
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.modules import sensors
|
||||
|
||||
# Globals
|
||||
sensors.__salt__ = {}
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class SensorTestCase(TestCase):
|
||||
'''
|
||||
Test cases for salt.modules.sensors
|
||||
'''
|
||||
def test_sense(self):
|
||||
'''
|
||||
Test to gather lm-sensors data from a given chip
|
||||
'''
|
||||
with patch.dict(sensors.__salt__,
|
||||
{'cmd.run': MagicMock(return_value='A:a B:b C:c D:d')}):
|
||||
self.assertDictEqual(sensors.sense('chip'), {'A': 'a B'})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
run_tests(SensorTestCase, needs_daemon=False)
|
Loading…
Add table
Reference in a new issue