예제 #1
0
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()
예제 #2
0
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()
예제 #3
0
 def postdeploy(self):
     ceph.unset_osd_noout(self.env)
     prepare.patch_puppet(revert=True)
예제 #4
0
 def prepare(self):
     self.preserve_partition()
     ceph.set_osd_noout(self.env)
     prepare.patch_puppet()
예제 #5
0
 def postdeploy(self):
     ceph.unset_osd_noout(self.env)
     prepare.patch_puppet(revert=True)
예제 #6
0
 def prepare(self):
     self.preserve_partition()
     ceph.set_osd_noout(self.env)
     prepare.patch_puppet()