Move the test_rehash test to test_win_functions

This commit is contained in:
twangboy 2018-02-08 17:43:03 -07:00
parent adc594c183
commit 29912adc15
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB
3 changed files with 10 additions and 38 deletions

View file

@ -254,7 +254,7 @@ def broadcast_setting_change(message='Environment'):
... code-block:: python
import salt.utils.win_functions
salt.utils.win_functions.refresh_environment()
salt.utils.win_functions.broadcast_setting_change('Environment')
'''
# Listen for messages sent by this would involve working with the
# SetWindowLong function. This can be accessed via the win32gui or through

View file

@ -20,49 +20,13 @@ from tests.support.mock import (
import salt.modules.win_path as win_path
class MockWin32API(object):
'''
Mock class for win32api
'''
def __init__(self):
pass
@staticmethod
def SendMessage(*args):
'''
Mock method for SendMessage
'''
return [args[0]]
class MockWin32Con(object):
'''
Mock class for win32con
'''
HWND_BROADCAST = 1
WM_SETTINGCHANGE = 1
def __init__(self):
pass
@skipIf(NO_MOCK, NO_MOCK_REASON)
class WinPathTestCase(TestCase, LoaderModuleMockMixin):
'''
Test cases for salt.modules.win_path
'''
def setup_loader_modules(self):
return {win_path: {'win32api': MockWin32API,
'win32con': MockWin32Con,
'SendMessage': MagicMock,
'HWND_BROADCAST': MagicMock,
'WM_SETTINGCHANGE': MagicMock}}
def test_rehash(self):
'''
Test to rehash the Environment variables
'''
self.assertTrue(win_path.rehash())
return {win_path: {}}
def test_get_path(self):
'''

View file

@ -12,6 +12,7 @@ from tests.support.mock import (
# Import Salt Libs
import salt.utils.win_functions as win_functions
import salt.utils
@skipIf(NO_MOCK, NO_MOCK_REASON)
@ -51,3 +52,10 @@ class WinFunctionsTestCase(TestCase):
encoded = win_functions.escape_argument('C:\\Some Path\\With Spaces')
self.assertEqual(encoded, '^"C:\\Some Path\\With Spaces^"')
@skipIf(not salt.utils.is_windows(), 'WinDLL only available on Windows')
def test_broadcast_setting_change(self):
'''
Test to rehash the Environment variables
'''
self.assertTrue(win_functions.broadcast_setting_change())