1
0

test_win_functions.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. from tests.support.mock import (
  7. NO_MOCK,
  8. NO_MOCK_REASON
  9. )
  10. # Import Salt Libs
  11. import salt.utils.platform
  12. import salt.utils.win_functions as win_functions
  13. @skipIf(NO_MOCK, NO_MOCK_REASON)
  14. class WinFunctionsTestCase(TestCase):
  15. '''
  16. Test cases for salt.utils.win_functions
  17. '''
  18. def test_escape_argument_simple(self):
  19. '''
  20. Test to make sure we encode simple arguments correctly
  21. '''
  22. encoded = win_functions.escape_argument('simple')
  23. self.assertEqual(encoded, 'simple')
  24. def test_escape_argument_with_space(self):
  25. '''
  26. Test to make sure we encode arguments containing spaces correctly
  27. '''
  28. encoded = win_functions.escape_argument('with space')
  29. self.assertEqual(encoded, '^"with space^"')
  30. def test_escape_argument_simple_path(self):
  31. '''
  32. Test to make sure we encode simple path arguments correctly
  33. '''
  34. encoded = win_functions.escape_argument('C:\\some\\path')
  35. self.assertEqual(encoded, 'C:\\some\\path')
  36. def test_escape_argument_path_with_space(self):
  37. '''
  38. Test to make sure we encode path arguments containing spaces correctly
  39. '''
  40. encoded = win_functions.escape_argument('C:\\Some Path\\With Spaces')
  41. self.assertEqual(encoded, '^"C:\\Some Path\\With Spaces^"')
  42. @skipIf(not salt.utils.platform.is_windows(), 'WinDLL only available on Windows')
  43. def test_broadcast_setting_change(self):
  44. '''
  45. Test to rehash the Environment variables
  46. '''
  47. self.assertTrue(win_functions.broadcast_setting_change())