1
0

test_mac_desktop.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # -*- coding: utf-8 -*-
  2. """
  3. Integration tests for the mac_desktop execution module.
  4. """
  5. from __future__ import absolute_import, print_function, unicode_literals
  6. from salt.ext import six
  7. from tests.support.case import ModuleCase
  8. from tests.support.helpers import destructiveTest, runs_on, skip_if_not_root, slowTest
  9. @destructiveTest
  10. @skip_if_not_root
  11. @runs_on(kernel="Darwin")
  12. class MacDesktopTestCase(ModuleCase):
  13. """
  14. Integration tests for the mac_desktop module.
  15. """
  16. def test_get_output_volume(self):
  17. """
  18. Tests the return of get_output_volume.
  19. """
  20. ret = self.run_function("desktop.get_output_volume")
  21. self.assertIsNotNone(ret)
  22. @slowTest
  23. def test_set_output_volume(self):
  24. """
  25. Tests the return of set_output_volume.
  26. """
  27. current_vol = self.run_function("desktop.get_output_volume")
  28. to_set = 10
  29. if current_vol == six.text_type(to_set):
  30. to_set += 2
  31. new_vol = self.run_function(
  32. "desktop.set_output_volume", [six.text_type(to_set)]
  33. )
  34. check_vol = self.run_function("desktop.get_output_volume")
  35. self.assertEqual(new_vol, check_vol)
  36. # Set volume back to what it was before
  37. self.run_function("desktop.set_output_volume", [current_vol])
  38. def test_screensaver(self):
  39. """
  40. Tests the return of the screensaver function.
  41. """
  42. self.assertTrue(self.run_function("desktop.screensaver"))
  43. def test_lock(self):
  44. """
  45. Tests the return of the lock function.
  46. """
  47. self.assertTrue(self.run_function("desktop.lock"))
  48. @slowTest
  49. def test_say(self):
  50. """
  51. Tests the return of the say function.
  52. """
  53. self.assertTrue(self.run_function("desktop.say", ["hello", "world"]))