test_win_functions.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- coding: utf-8 -*-
  2. # Import Python Libs
  3. from __future__ import absolute_import, unicode_literals, print_function
  4. # Import Salt Testing Libs
  5. from tests.support.unit import TestCase, skipIf
  6. # Import Salt Libs
  7. import salt.utils.platform
  8. import salt.utils.win_functions as win_functions
  9. class WinFunctionsTestCase(TestCase):
  10. '''
  11. Test cases for salt.utils.win_functions
  12. '''
  13. def test_escape_argument_simple(self):
  14. '''
  15. Test to make sure we encode simple arguments correctly
  16. '''
  17. encoded = win_functions.escape_argument('simple')
  18. self.assertEqual(encoded, 'simple')
  19. def test_escape_argument_with_space(self):
  20. '''
  21. Test to make sure we encode arguments containing spaces correctly
  22. '''
  23. encoded = win_functions.escape_argument('with space')
  24. self.assertEqual(encoded, '^"with space^"')
  25. def test_escape_argument_simple_path(self):
  26. '''
  27. Test to make sure we encode simple path arguments correctly
  28. '''
  29. encoded = win_functions.escape_argument('C:\\some\\path')
  30. self.assertEqual(encoded, 'C:\\some\\path')
  31. def test_escape_argument_path_with_space(self):
  32. '''
  33. Test to make sure we encode path arguments containing spaces correctly
  34. '''
  35. encoded = win_functions.escape_argument('C:\\Some Path\\With Spaces')
  36. self.assertEqual(encoded, '^"C:\\Some Path\\With Spaces^"')
  37. @skipIf(not salt.utils.platform.is_windows(), 'WinDLL only available on Windows')
  38. def test_broadcast_setting_change(self):
  39. '''
  40. Test to rehash the Environment variables
  41. '''
  42. self.assertTrue(win_functions.broadcast_setting_change())