1
0

test_macdefaults.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Validate the mac-defaults 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. from tests.support.helpers import destructiveTest, skip_if_not_root
  10. DEFAULT_DOMAIN = 'com.apple.AppleMultitouchMouse'
  11. DEFAULT_KEY = 'MouseHorizontalScroll'
  12. DEFAULT_VALUE = '0'
  13. @destructiveTest
  14. @skip_if_not_root
  15. class MacDefaultsModuleTest(ModuleCase):
  16. '''
  17. Integration tests for the mac_default module
  18. '''
  19. def setUp(self):
  20. '''
  21. Sets up the test requirements
  22. '''
  23. os_grain = self.run_function('grains.item', ['kernel'])
  24. # Must be running on a mac
  25. if os_grain['kernel'] not in 'Darwin':
  26. self.skipTest(
  27. 'Test not applicable to \'{kernel}\' kernel'.format(
  28. **os_grain
  29. )
  30. )
  31. def test_macdefaults_write_read(self):
  32. '''
  33. Tests that writes and reads macdefaults
  34. '''
  35. write_domain = self.run_function('macdefaults.write',
  36. [DEFAULT_DOMAIN,
  37. DEFAULT_KEY,
  38. DEFAULT_VALUE])
  39. self.assertTrue(write_domain)
  40. read_domain = self.run_function('macdefaults.read',
  41. [DEFAULT_DOMAIN,
  42. DEFAULT_KEY])
  43. self.assertTrue(read_domain)
  44. self.assertEqual(read_domain, DEFAULT_VALUE)