"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/states/test_lvm.py" between
salt-3002.1.tar.gz and salt-3002.2.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

test_lvm.py  (salt-3002.1):test_lvm.py  (salt-3002.2)
""" """
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com> :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
""" """
# Import Python libs
# Import Salt Libs
import salt.states.lvm as lvm import salt.states.lvm as lvm
# Import Salt Testing Libs
from tests.support.mixins import LoaderModuleMockMixin from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase from tests.support.unit import TestCase
STUB_LVDISPLAY_LV01 = { STUB_LVDISPLAY_LV01 = {
"/dev/testvg01/testlv01": { "/dev/testvg01/testlv01": {
"Logical Volume Name": "/dev/testvg01/testlv01", "Logical Volume Name": "/dev/testvg01/testlv01",
"Volume Group Name": "testvg01", "Volume Group Name": "testvg01",
"Logical Volume Access": "3", "Logical Volume Access": "3",
"Logical Volume Status": "1", "Logical Volume Status": "1",
skipping to change at line 165 skipping to change at line 161
with patch.dict(lvm.__salt__, {"lvm.lvdisplay": mock}): with patch.dict(lvm.__salt__, {"lvm.lvdisplay": mock}):
self.assertDictEqual(lvm.lv_present(name, vgname=vgname), ret) self.assertDictEqual(lvm.lv_present(name, vgname=vgname), ret)
mock = MagicMock(return_value=STUB_LVDISPLAY_LV02) mock = MagicMock(return_value=STUB_LVDISPLAY_LV02)
with patch.dict(lvm.__salt__, {"lvm.lvdisplay": mock}): with patch.dict(lvm.__salt__, {"lvm.lvdisplay": mock}):
comt = "Logical Volume {} is set to be created".format(name) comt = "Logical Volume {} is set to be created".format(name)
ret.update({"comment": comt, "result": None}) ret.update({"comment": comt, "result": None})
with patch.dict(lvm.__opts__, {"test": True}): with patch.dict(lvm.__opts__, {"test": True}):
self.assertDictEqual(lvm.lv_present(name, vgname=vgname), ret) self.assertDictEqual(lvm.lv_present(name, vgname=vgname), ret)
def test_lv_present_with_percentage_extents(self):
"""
Test do create a new logical volume specifying extents as a percentage
"""
name = "testlv01"
vgname = "testvg01"
extents = "42%FREE"
comt = "Logical Volume {} already present, {} won't be resized.".format(
name, extents
)
ret = {"name": name, "changes": {}, "result": True, "comment": comt}
mock = MagicMock(return_value=STUB_LVDISPLAY_LV01)
with patch.dict(lvm.__salt__, {"lvm.lvdisplay": mock}):
self.assertDictEqual(
lvm.lv_present(name, vgname=vgname, extents=extents), ret
)
extents = "42%VG"
mock = MagicMock(return_value=STUB_LVDISPLAY_LV02)
with patch.dict(lvm.__salt__, {"lvm.lvdisplay": mock}):
comt = "Logical Volume {} is set to be created".format(name)
ret.update({"comment": comt, "result": None})
with patch.dict(lvm.__opts__, {"test": True}):
self.assertDictEqual(
lvm.lv_present(name, vgname=vgname, extents=extents), ret
)
def test_lv_present_with_force(self): def test_lv_present_with_force(self):
""" """
Test to create a new logical volume with force=True Test to create a new logical volume with force=True
""" """
name = "testlv01" name = "testlv01"
vgname = "testvg01" vgname = "testvg01"
comt = "Logical Volume {} already present".format(name) comt = "Logical Volume {} already present".format(name)
ret = {"name": name, "changes": {}, "result": True, "comment": comt} ret = {"name": name, "changes": {}, "result": True, "comment": comt}
mock = MagicMock(return_value=STUB_LVDISPLAY_LV01) mock = MagicMock(return_value=STUB_LVDISPLAY_LV01)
 End of changes. 4 change blocks. 
4 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)