test_macdefaults.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 pytest
  8. # Import Salt Testing Libs
  9. from tests.support.case import ModuleCase
  10. DEFAULT_DOMAIN = 'com.apple.AppleMultitouchMouse'
  11. DEFAULT_KEY = 'MouseHorizontalScroll'
  12. DEFAULT_VALUE = '0'
  13. @pytest.mark.destructive_test
  14. @pytest.mark.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)