2016-03-23 23:31:41 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
|
|
Integration tests for the mac_desktop execution module.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Import Python Libs
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import os
|
|
|
|
|
|
|
|
# Import Salt Testing Libs
|
2017-02-27 15:59:04 +00:00
|
|
|
import tests.integration as integration
|
2017-02-27 13:58:07 +00:00
|
|
|
from tests.support.unit import skipIf
|
2017-03-29 18:15:15 +00:00
|
|
|
from tests.support.helpers import destructiveTest
|
2016-03-23 23:31:41 +00:00
|
|
|
|
|
|
|
|
2017-03-29 18:15:15 +00:00
|
|
|
@destructiveTest
|
2016-03-23 23:31:41 +00:00
|
|
|
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
|
|
class MacDesktopTestCase(integration.ModuleCase):
|
|
|
|
'''
|
|
|
|
Integration tests for the mac_desktop module.
|
|
|
|
'''
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
'''
|
|
|
|
Sets up test requirements.
|
|
|
|
'''
|
|
|
|
os_grain = self.run_function('grains.item', ['kernel'])
|
|
|
|
if os_grain['kernel'] not in 'Darwin':
|
|
|
|
self.skipTest(
|
|
|
|
'Test not applicable to \'{kernel}\' kernel'.format(
|
|
|
|
**os_grain
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2017-03-29 18:15:15 +00:00
|
|
|
def test_get_output_volume(self):
|
2016-03-23 23:31:41 +00:00
|
|
|
'''
|
|
|
|
Tests the return of get_output_volume.
|
|
|
|
'''
|
|
|
|
ret = self.run_function('desktop.get_output_volume')
|
|
|
|
self.assertIsNotNone(ret)
|
|
|
|
|
2017-03-29 18:15:15 +00:00
|
|
|
def test_set_output_volume(self):
|
2016-03-23 23:31:41 +00:00
|
|
|
'''
|
|
|
|
Tests the return of set_output_volume.
|
|
|
|
'''
|
|
|
|
current_vol = self.run_function('desktop.get_output_volume')
|
|
|
|
to_set = 10
|
|
|
|
if current_vol == str(to_set):
|
|
|
|
to_set += 2
|
|
|
|
new_vol = self.run_function('desktop.set_output_volume', [str(to_set)])
|
|
|
|
check_vol = self.run_function('desktop.get_output_volume')
|
|
|
|
self.assertEqual(new_vol, check_vol)
|
|
|
|
|
|
|
|
# Set volume back to what it was before
|
|
|
|
self.run_function('desktop.set_output_volume', [current_vol])
|
|
|
|
|
2017-03-29 18:15:15 +00:00
|
|
|
def test_screensaver(self):
|
2016-03-23 23:31:41 +00:00
|
|
|
'''
|
|
|
|
Tests the return of the screensaver function.
|
|
|
|
'''
|
|
|
|
self.assertTrue(
|
|
|
|
self.run_function('desktop.screensaver')
|
|
|
|
)
|
|
|
|
|
2017-03-29 18:15:15 +00:00
|
|
|
def test_lock(self):
|
2016-03-23 23:31:41 +00:00
|
|
|
'''
|
|
|
|
Tests the return of the lock function.
|
|
|
|
'''
|
|
|
|
self.assertTrue(
|
|
|
|
self.run_function('desktop.lock')
|
|
|
|
)
|
|
|
|
|
2017-03-29 18:15:15 +00:00
|
|
|
def test_say(self):
|
2016-03-23 23:31:41 +00:00
|
|
|
'''
|
|
|
|
Tests the return of the say function.
|
|
|
|
'''
|
|
|
|
self.assertTrue(
|
|
|
|
self.run_function('desktop.say', ['hello', 'world'])
|
|
|
|
)
|