Exemplo n.º 1
0
def test_pv_absent():
    """
    Test to ensure that a Physical Device is not being used by lvm
    """
    name = "/dev/sda5"

    comt = "Physical Volume {} does not exist".format(name)

    ret = {"name": name, "changes": {}, "result": True, "comment": comt}

    mock = MagicMock(side_effect=[False, True])
    with patch.dict(lvm.__salt__, {"lvm.pvdisplay": mock}):
        assert lvm.pv_absent(name) == ret

        comt = "Physical Volume {} is set to be removed".format(name)
        ret.update({"comment": comt, "result": None})
        with patch.dict(lvm.__opts__, {"test": True}):
            assert lvm.pv_absent(name) == ret
Exemplo n.º 2
0
    def test_pv_absent(self):
        '''
        Test to ensure that a Physical Device is not being used by lvm
        '''
        name = '/dev/sda5'

        comt = ('Physical Volume {0} does not exist'.format(name))

        ret = {'name': name, 'changes': {}, 'result': True, 'comment': comt}

        mock = MagicMock(side_effect=[False, True])
        with patch.dict(lvm.__salt__, {'lvm.pvdisplay': mock}):
            self.assertDictEqual(lvm.pv_absent(name), ret)

            comt = ('Physical Volume {0} is set to be removed'.format(name))
            ret.update({'comment': comt, 'result': None})
            with patch.dict(lvm.__opts__, {'test': True}):
                self.assertDictEqual(lvm.pv_absent(name), ret)