Ejemplo n.º 1
0
def test_rename_success(utils_patch):
    """
    Tests successful return of rename function
    """
    res = OrderedDict([("renamed", True)])
    ret = {}
    ret["stdout"] = ""
    ret["stderr"] = ""
    ret["retcode"] = 0
    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.rename("myzpool/mydataset", "myzpool/newdataset")
Ejemplo n.º 2
0
def test_rename_error_not_exists(utils_patch):
    """
    Tests failure return of rename function
    """
    res = OrderedDict([
        ("renamed", False),
        ("error", "cannot open 'myzpool/mydataset': dataset does not exist"),
    ])
    ret = {}
    ret["stdout"] = ""
    ret["stderr"] = "cannot open 'myzpool/mydataset': dataset does not exist"
    ret["retcode"] = 1
    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.rename("myzpool/mydataset", "myzpool/newdataset")