Beispiel #1
0
def test_hold_failure(utils_patch):
    """
    Tests zfs hold failure
    """
    res = OrderedDict([
        ("held", False),
        (
            "error",
            "cannot hold snapshot 'myzpool/mydataset@baseline': tag already"
            " exists on this dataset",
        ),
    ])
    ret = {
        "pid":
        51006,
        "retcode":
        1,
        "stderr":
        ("cannot hold snapshot 'myzpool/mydataset@baseline': tag already exists"
         " on this dataset"),
        "stdout":
        "",
    }
    mock_cmd = MagicMock(return_value=ret)
    with patch.dict(zfs.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
            zfs.__utils__, utils_patch):
        assert res == zfs.hold("important", "myzpool/mydataset@baseline")
Beispiel #2
0
 def test_hold_failure(self):
     '''
     Tests zfs hold failure
     '''
     res = {'myzpool/mydataset@baseline': {'important': 'tag already exists on this dataset'}}
     ret = {'pid': 51006, 'retcode': 1, 'stderr': "cannot hold snapshot 'myzpool/mydataset@baseline': tag already exists on this dataset", 'stdout': ''}
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}):
         self.assertEqual(zfs.hold('important', 'myzpool/mydataset@baseline'), res)
Beispiel #3
0
 def test_hold_success(self):
     '''
     Tests zfs hold success
     '''
     res = {'myzpool/mydataset@baseline': {'important': 'held'}, 'myzpool/[email protected]': {'important': 'held'}}
     ret = {'pid': 50876, 'retcode': 0, 'stderr': '', 'stdout': ''}
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}):
         self.assertEqual(zfs.hold('important', 'myzpool/mydataset@baseline', 'myzpool/[email protected]'), res)
Beispiel #4
0
def test_hold_success(utils_patch):
    """
    Tests zfs hold success
    """
    res = OrderedDict([("held", True)])
    ret = {"pid": 50876, "retcode": 0, "stderr": "", "stdout": ""}
    mock_cmd = MagicMock(return_value=ret)
    with patch.dict(zfs.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
            zfs.__utils__, utils_patch):
        assert res == zfs.hold(
            "important",
            "myzpool/mydataset@baseline",
            "myzpool/[email protected]",
        )