Пример #1
0
def test_pv_present():
    """
    Test to set a physical device to be used as an LVM physical volume
    """
    name = "/dev/sda5"

    comt = "Physical Volume {} already present".format(name)

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

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

        comt = "Physical Volume {} is set to be created".format(name)
        ret.update({"comment": comt, "result": None})
        with patch.dict(lvm.__opts__, {"test": True}):
            assert lvm.pv_present(name) == ret
Пример #2
0
    def test_pv_present(self):
        '''
        Test to set a physical device to be used as an LVM physical volume
        '''
        name = '/dev/sda5'

        comt = ('Physical Volume {0} already present'.format(name))

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

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

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