1
0

test_mac_desktop.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Integration tests for the mac_desktop execution module.
  4. '''
  5. # Import Python Libs
  6. from __future__ import absolute_import, unicode_literals, print_function
  7. # Import Salt Testing Libs
  8. from tests.support.case import ModuleCase
  9. # Import 3rd-party libs
  10. import pytest
  11. from salt.ext import six
  12. @pytest.mark.destructive_test
  13. @pytest.mark.skip_if_not_root
  14. class MacDesktopTestCase(ModuleCase):
  15. '''
  16. Integration tests for the mac_desktop module.
  17. '''
  18. def setUp(self):
  19. '''
  20. Sets up test requirements.
  21. '''
  22. os_grain = self.run_function('grains.item', ['kernel'])
  23. if os_grain['kernel'] not in 'Darwin':
  24. self.skipTest(
  25. 'Test not applicable to \'{kernel}\' kernel'.format(
  26. **os_grain
  27. )
  28. )
  29. def test_get_output_volume(self):
  30. '''
  31. Tests the return of get_output_volume.
  32. '''
  33. ret = self.run_function('desktop.get_output_volume')
  34. self.assertIsNotNone(ret)
  35. def test_set_output_volume(self):
  36. '''
  37. Tests the return of set_output_volume.
  38. '''
  39. current_vol = self.run_function('desktop.get_output_volume')
  40. to_set = 10
  41. if current_vol == six.text_type(to_set):
  42. to_set += 2
  43. new_vol = self.run_function('desktop.set_output_volume',
  44. [six.text_type(to_set)])
  45. check_vol = self.run_function('desktop.get_output_volume')
  46. self.assertEqual(new_vol, check_vol)
  47. # Set volume back to what it was before
  48. self.run_function('desktop.set_output_volume', [current_vol])
  49. def test_screensaver(self):
  50. '''
  51. Tests the return of the screensaver function.
  52. '''
  53. self.assertTrue(
  54. self.run_function('desktop.screensaver')
  55. )
  56. def test_lock(self):
  57. '''
  58. Tests the return of the lock function.
  59. '''
  60. self.assertTrue(
  61. self.run_function('desktop.lock')
  62. )
  63. def test_say(self):
  64. '''
  65. Tests the return of the say function.
  66. '''
  67. self.assertTrue(
  68. self.run_function('desktop.say', ['hello', 'world'])
  69. )