mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix test for modules.linux_lvm.pvcreate
pvdisplay() would be called by pvcreate() twice: firstly to check whether a device is already initialized for use by LVM and then to ensure that the pvcreate executable did its job correctly. The test replaces pvdisplay() with a mock that always returns True and thus pvcreate() would think that a specified device is already initialized and exit. In the other words, instead of testing physical volume initialization the test simulates a case with all the submitted devices already initialized. Fix it by replacing pvdisplay with a mock that returns False on the first call (thus pvcreate thinks that a device is not a PV yet) and True on the second call (after the pvcreate executable is called).
This commit is contained in:
parent
88b171f863
commit
3967992bfd
1 changed files with 4 additions and 1 deletions
|
@ -152,7 +152,10 @@ class LinuxLVMTestCase(TestCase):
|
|||
|
||||
self.assertRaises(CommandExecutionError, linux_lvm.pvcreate, 'A')
|
||||
|
||||
pvdisplay = MagicMock(return_value=True)
|
||||
# pvdisplay() would be called by pvcreate() twice: firstly to check
|
||||
# whether a device is already initialized for use by LVM and then to
|
||||
# ensure that the pvcreate executable did its job correctly.
|
||||
pvdisplay = MagicMock(side_effect=[False, True])
|
||||
with patch('salt.modules.linux_lvm.pvdisplay', pvdisplay):
|
||||
with patch.object(os.path, 'exists', return_value=True):
|
||||
ret = {'stdout': 'saltines', 'stderr': 'cheese', 'retcode': 0, 'pid': '1337'}
|
||||
|
|
Loading…
Add table
Reference in a new issue