Example #1
0
    def test_remove(self):
        '''
            Test to remove the directory from the SYSTEM path
        '''
        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_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"))
Example #2
0
    def test_remove(self):
        """
            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):
            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):
                    self.assertEqual(win_path.remove("c:\\salt"), "Salt")

                self.assertFalse(win_path.remove("c:\\salt"))
Example #3
0
    def test_remove(self):
        '''
            Test to remove the directory from the SYSTEM path
        '''
        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_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"))
Example #4
0
 def _run(name='c:\\salt', index=None, retval=True, path=None):
     if path is None:
         path = orig_path
     env = _env(path)
     mock_get = MagicMock(return_value=list(path))
     mock_set = MagicMock(return_value=retval)
     with patch.object(win_path, 'PATHSEP', self.pathsep), \
             patch.object(win_path, 'get_path', mock_get), \
             patch.object(os, 'environ', env), \
             patch.dict(win_path.__utils__, {'reg.set_value': mock_set}), \
             patch.object(win_path, 'rehash', MagicMock(return_value=True)):
         return win_path.remove(name), env, mock_set
Example #5
0
 def _run(name="c:\\salt", index=None, retval=True, path=None):
     if path is None:
         path = orig_path
     env = _env(path)
     mock_get = MagicMock(return_value=list(path))
     mock_set = MagicMock(return_value=retval)
     with patch.object(win_path, "PATHSEP", self.pathsep), patch.object(
             win_path, "get_path",
             mock_get), patch.object(os, "environ", env), patch.dict(
                 win_path.__salt__,
                 {"reg.set_value": mock_set}), patch.object(
                     win_path, "rehash", MagicMock(return_value=True)):
         return win_path.remove(name), env, mock_set
Example #6
0
    def _run(name="c:\\salt", retval=True, path=None):
        if path is None:
            path = orig_path
        env = _env(path)
        # Mock getters and setters
        mock_get = MagicMock(return_value=list(path))
        mock_set = MagicMock(return_value=retval)

        patch_path_sep = patch.object(win_path, "PATHSEP", pathsep)
        patch_path = patch.object(win_path, "get_path", mock_get)
        patch_env = patch.object(os, "environ", env)
        patch_dict = patch.dict(win_path.__utils__, {"reg.set_value": mock_set})
        patch_rehash = patch.object(win_path, "rehash", MagicMock(return_value=True))
        with patch_path_sep, patch_path, patch_env, patch_dict, patch_rehash:
            return win_path.remove(name), env, mock_set