mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Fixing unit tests for mdadm
This commit is contained in:
parent
48c5b32b81
commit
502b340553
@ -28,34 +28,34 @@ class MdadmTestCase(TestCase):
|
|||||||
with patch.dict(mdadm.__salt__, {'cmd.run': mock}):
|
with patch.dict(mdadm.__salt__, {'cmd.run': mock}):
|
||||||
ret = mdadm.create(
|
ret = mdadm.create(
|
||||||
'/dev/md0', 5,
|
'/dev/md0', 5,
|
||||||
['/dev/sdb1',
|
devices="['/dev/sdb1',
|
||||||
'/dev/sdc1',
|
'/dev/sdc1',
|
||||||
'/dev/sdd1'],
|
'/dev/sdd1']",
|
||||||
test_mode=False,
|
test_mode=False,
|
||||||
force=True,
|
force=True,
|
||||||
chunk=256
|
chunk=256
|
||||||
)
|
)
|
||||||
self.assertEqual('salt', ret)
|
self.assertEqual('salt', ret)
|
||||||
mock.assert_called_once_with(
|
mock.assert_called_once_with(
|
||||||
['mdadm', '-C', '/dev/md0', '-v', '--chunk', 256, '--force',
|
'mdadm -C /dev/md0 -v --chunk 256 --force
|
||||||
'-l', 5, '-e', 'default', '-n', 3, '/dev/sdb1', '/dev/sdc1',
|
-l 5 -e default -n 3 /dev/sdb1 /dev/sdc1
|
||||||
'/dev/sdd1'], python_shell=False)
|
/dev/sdd1', python_shell=False)
|
||||||
|
|
||||||
def test_create_test_mode(self):
|
def test_create_test_mode(self):
|
||||||
mock = MagicMock()
|
mock = MagicMock()
|
||||||
with patch.dict(mdadm.__salt__, {'cmd.run': mock}):
|
with patch.dict(mdadm.__salt__, {'cmd.run': mock}):
|
||||||
ret = mdadm.create(
|
ret = mdadm.create(
|
||||||
'/dev/md0', 5,
|
'/dev/md0', 5,
|
||||||
['/dev/sdb1',
|
devices="['/dev/sdb1',
|
||||||
'/dev/sdc1',
|
'/dev/sdc1',
|
||||||
'/dev/sdd1'],
|
'/dev/sdd1']",
|
||||||
force=True,
|
force=True,
|
||||||
chunk=256,
|
chunk=256,
|
||||||
test_mode=True
|
test_mode=True
|
||||||
)
|
)
|
||||||
self.assertEqual(['mdadm', '-C', '/dev/md0', '-v', '--chunk', 256,
|
self.assertEqual(['mdadm -C /dev/md0 -v --chunk 256 '
|
||||||
'--force', '-l', 5, '-e', 'default', '-n', 3,
|
'--force -l 5 -e default -n 3 '
|
||||||
'/dev/sdb1', '/dev/sdc1', '/dev/sdd1'], ret)
|
'/dev/sdb1 /dev/sdc1 /dev/sdd1'], ret)
|
||||||
assert not mock.called, 'test mode failed, cmd.run called'
|
assert not mock.called, 'test mode failed, cmd.run called'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user