Merge pull request #27030 from jfindlay/winreg

Backport #26938
This commit is contained in:
Nicole Thomas 2015-09-11 09:10:45 -06:00
commit e23caa8ccf
2 changed files with 17 additions and 17 deletions

View file

@ -146,11 +146,11 @@ def add(path, index=0):
# Add it to the Path
sysPath.insert(index, path)
regedit = __salt__['reg.set_key'](
regedit = __salt__['reg.set_value'](
'HKEY_LOCAL_MACHINE',
'SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment',
'PATH',
';'.join(sysPath),
'PATH',
'REG_EXPAND_SZ'
)
@ -183,11 +183,11 @@ def remove(path):
except ValueError:
return True
regedit = __salt__['reg.set_key'](
regedit = __salt__['reg.set_value'](
'HKEY_LOCAL_MACHINE',
'SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment',
'PATH',
';'.join(sysPath),
'PATH',
'REG_EXPAND_SZ'
)
if regedit:

View file

@ -69,7 +69,7 @@ class WinPathTestCase(TestCase):
'''
Test to Returns the system path
'''
mock = MagicMock(return_value='c:\\salt')
mock = MagicMock(return_value={'vdata': 'c:\\salt'})
with patch.dict(win_path.__salt__, {'reg.read_key': mock}):
self.assertListEqual(win_path.get_path(), ['c:\\salt'])
@ -85,12 +85,12 @@ class WinPathTestCase(TestCase):
'''
Test to add the directory to the SYSTEM path
'''
mock = MagicMock(return_value=['c:\\salt'])
with patch.object(win_path, 'get_path', mock):
mock = MagicMock(return_value=True)
with patch.dict(win_path.__salt__, {'reg.set_key': mock}):
mock = MagicMock(side_effect=[True, False])
with patch.object(win_path, 'rehash', mock):
mock_get = MagicMock(return_value=['c:\\salt'])
with patch.object(win_path, 'get_path', mock_get):
mock_set = MagicMock(return_value=True)
with patch.dict(win_path.__salt__, {'reg.set_value': mock_set}):
mock_rehash = MagicMock(side_effect=[True, False])
with patch.object(win_path, 'rehash', mock_rehash):
self.assertTrue(win_path.add("c:\\salt", 1))
self.assertFalse(win_path.add("c:\\salt", 1))
@ -99,14 +99,14 @@ class WinPathTestCase(TestCase):
'''
Test to remove the directory from the SYSTEM path
'''
mock = MagicMock(side_effect=[[1], ['c:\\salt'], ['c:\\salt']])
with patch.object(win_path, 'get_path', mock):
mock_get = MagicMock(side_effect=[[1], ['c:\\salt'], ['c:\\salt']])
with patch.object(win_path, 'get_path', mock_get):
self.assertTrue(win_path.remove("c:\\salt"))
mock = MagicMock(side_effect=[True, False])
with patch.dict(win_path.__salt__, {'reg.set_key': mock}):
mock = MagicMock(return_value="Salt")
with patch.object(win_path, 'rehash', mock):
mock_set = MagicMock(side_effect=[True, False])
with patch.dict(win_path.__salt__, {'reg.set_value': mock_set}):
mock_rehash = MagicMock(return_value="Salt")
with patch.object(win_path, 'rehash', mock_rehash):
self.assertEqual(win_path.remove("c:\\salt"), "Salt")
self.assertFalse(win_path.remove("c:\\salt"))