2015-05-08 10:41:20 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
|
|
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
|
|
|
'''
|
|
|
|
# Import Python libs
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
# Import Salt Testing Libs
|
2017-03-21 17:57:27 +00:00
|
|
|
from tests.support.mixins import LoaderModuleMockMixin
|
2017-02-27 13:58:07 +00:00
|
|
|
from tests.support.unit import skipIf, TestCase
|
|
|
|
from tests.support.mock import (
|
2015-05-08 10:41:20 +00:00
|
|
|
NO_MOCK,
|
|
|
|
NO_MOCK_REASON,
|
|
|
|
MagicMock,
|
|
|
|
patch)
|
|
|
|
|
|
|
|
# Import Salt Libs
|
2017-03-21 17:15:36 +00:00
|
|
|
import salt.modules.sensors as sensors
|
2015-05-08 10:41:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
2017-03-21 17:57:27 +00:00
|
|
|
class SensorTestCase(TestCase, LoaderModuleMockMixin):
|
2015-05-08 10:41:20 +00:00
|
|
|
'''
|
|
|
|
Test cases for salt.modules.sensors
|
|
|
|
'''
|
2017-03-21 17:57:27 +00:00
|
|
|
loader_module = sensors
|
|
|
|
|
2015-05-08 10:41:20 +00:00
|
|
|
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'})
|