def test_vg_present(self): """ Test to create an LVM volume group """ name = "/dev/sda5" comt = "Failed to create Volume Group {0}".format(name) ret = {"name": name, "changes": {}, "result": False, "comment": comt} mock = MagicMock(return_value=False) with patch.dict(lvm.__salt__, {"lvm.vgdisplay": mock, "lvm.vgcreate": mock}): with patch.dict(lvm.__opts__, {"test": False}): self.assertDictEqual(lvm.vg_present(name), ret) comt = "Volume Group {0} is set to be created".format(name) ret.update({"comment": comt, "result": None}) with patch.dict(lvm.__opts__, {"test": True}): self.assertDictEqual(lvm.vg_present(name), ret)
def test_vg_present(self): ''' Test to create an LVM volume group ''' name = '/dev/sda5' comt = ('Failed to create Volume Group {0}'.format(name)) ret = {'name': name, 'changes': {}, 'result': False, 'comment': comt} mock = MagicMock(return_value=False) with patch.dict(lvm.__salt__, { 'lvm.vgdisplay': mock, 'lvm.vgcreate': mock }): with patch.dict(lvm.__opts__, {'test': False}): self.assertDictEqual(lvm.vg_present(name), ret) comt = ('Volume Group {0} is set to be created'.format(name)) ret.update({'comment': comt, 'result': None}) with patch.dict(lvm.__opts__, {'test': True}): self.assertDictEqual(lvm.vg_present(name), ret)