@@ -0,0 +1,1671 @@
+# -*- coding: utf-8 -*-%0A'''%0Amac_power tests%0A'''%0A%0A# Import python libs%0Afrom __future__ import absolute_import%0A%0A# Import Salt Testing Libs%0Afrom salttesting import TestCase, skipIf%0Afrom salttesting.helpers import ensure_in_syspath%0Afrom salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON%0A%0Aensure_in_syspath('../../')%0A%0A# Import Salt Libs%0Afrom salt.modules import mac_power%0Afrom salt.utils import mac_utils%0Afrom salt.exceptions import SaltInvocationError%0A%0Amac_utils.__salt__ = %7B%7D%0A%0A%0A@skipIf(NO_MOCK, NO_MOCK_REASON)%0Aclass MacPowerTestCase(TestCase):%0A    '''%0A    test mac_power execution module%0A    '''%0A    def test_set_sleep(self):%0A        '''%0A        test set_sleep function%0A        '''%0A        mock_cmd = MagicMock(return_value=%7B'retcode': 0, 'stdout': 'spongebob'%7D)%0A        with patch.dict(mac_utils.__salt__, %7B'cmd.run_all': mock_cmd%7D):%0A            ret = mac_power.set_sleep(179)%0A            mock_cmd.assert_called_once_with('systemsetup -setsleep 179')%0A            self.assertEqual(ret, True)%0A%0A        mock_cmd = MagicMock(return_value=%7B'retcode': 0, 'stdout': 'spongebob'%7D)%0A        with patch.dict(mac_utils.__salt__, %7B'cmd.run_all': mock_cmd%7D):%0A            ret = mac_power.set_sleep('never')%0A            mock_cmd.assert_called_once_with('systemsetup -setsleep never')%0A            self.assertEqual(ret, True)%0A%0A        mock_cmd = MagicMock(return_value=%7B'retcode': 1, 'stdout': 'plankton'%7D)%0A        with patch.dict(mac_utils.__salt__, %7B'cmd.run_all': mock_cmd%7D):%0A            self.assertRaises(SaltInvocationError, mac_power.set_sleep, 181)%0A%0Aif __name__ == '__main__':%0A    from integration import run_tests%0A    run_tests(MacPowerTestCase, needs_daemon=False)%0A

add unit tests