def test_simple_patch(mocker, mock_subprocess, mock_open, revert, patch_dirs): os_dirs = [] is_dir_list = [] patch_files = [] for indx, (is_dir, is_exception_on_revert) in enumerate(patch_dirs): patch_dir = "patch_{0}".format(indx) os_dirs.append(patch_dir) is_dir_list.append(is_dir) if is_dir: patch_files.append(MockFile(is_exception_on_revert, revert)) mock_list_dir = mocker.patch("os.listdir", return_value=os_dirs) mock_is_dir = mocker.patch("os.path.isdir", side_effect=is_dir_list) mock_open.return_value.__enter__.side_effect = patch_files mock_subprocess.side_effect = _read_in_subprocess prepare.patch_puppet(revert) path_arg = '/'.join([magic_consts.CWD, "patches", "puppet"]) mock_list_dir.assert_called_once_with(path_arg) path_args = [mock.call('/'.join([path_arg, i])) for i in os_dirs] assert path_args == mock_is_dir.call_args_list for mock_open_file in patch_files: mock_open_file.assert_calls()
def test_simple_patch(mocker, mock_subprocess, mock_open, revert, patch_dirs): os_dirs = [] is_dir_list = [] patch_files = [] for indx, (is_dir, is_exception_on_revert) in enumerate(patch_dirs): patch_dir = "patch_{0}".format(indx) os_dirs.append(patch_dir) is_dir_list.append(is_dir) if is_dir: patch_files.append(MockFile(is_exception_on_revert, revert)) mock_list_dir = mocker.patch("os.listdir", return_value=os_dirs) mock_is_dir = mocker.patch("os.path.isdir", side_effect=is_dir_list) mock_open.return_value.__enter__.side_effect = patch_files mock_subprocess.side_effect = _read_in_subprocess prepare.patch_puppet(revert) path_arg = '/'.join([magic_consts.CWD, "patches", "puppet"]) mock_list_dir.assert_called_once_with(path_arg) path_args = [mock.call('/'.join([path_arg, i])) for i in os_dirs] assert path_args == mock_is_dir.call_args_list for mock_open_file in patch_files: mock_open_file.assert_calls()
def postdeploy(self): ceph.unset_osd_noout(self.env) prepare.patch_puppet(revert=True)
def prepare(self): self.preserve_partition() ceph.set_osd_noout(self.env) prepare.patch_puppet()
def postdeploy(self): ceph.unset_osd_noout(self.env) prepare.patch_puppet(revert=True)
def prepare(self): self.preserve_partition() ceph.set_osd_noout(self.env) prepare.patch_puppet()