Merge pull request #41874 from DSRCorporation/bugs/py3_mdadm_test

Py3 mdadm test
This commit is contained in:
Mike Place 2017-06-21 12:03:33 -05:00 committed by GitHub
commit eea9cafba0

View File

@ -18,9 +18,6 @@ from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch
# Import salt libs # Import salt libs
import salt.modules.mdadm as mdadm import salt.modules.mdadm as mdadm
# Import 3rd-party libs
import salt.ext.six as six
@skipIf(NO_MOCK, NO_MOCK_REASON) @skipIf(NO_MOCK, NO_MOCK_REASON)
class MdadmTestCase(TestCase, LoaderModuleMockMixin): class MdadmTestCase(TestCase, LoaderModuleMockMixin):
@ -40,32 +37,26 @@ class MdadmTestCase(TestCase, LoaderModuleMockMixin):
chunk=256 chunk=256
) )
self.assertEqual('salt', ret) self.assertEqual('salt', ret)
if six.PY2: mock.assert_called_once()
expected_args = [ args, kwargs = mock.call_args
'mdadm', # expected cmd is
'-C', '/dev/md0', # mdadm -C /dev/md0 -R -v --chunk 256 --force -l 5 -e default -n 3 /dev/sdb1 /dev/sdc1 /dev/sdd1
'-R', # where args between -v and -l could be in any order
'-v', self.assertEqual(len(args), 1)
'--chunk', '256', self.assertEqual(len(args[0]), 17)
'--force', self.assertEqual(args[0][:5], [
'-l', '5', 'mdadm',
'-e', 'default', '-C', '/dev/md0',
'-n', '3', '-R',
'/dev/sdb1', '/dev/sdc1', '/dev/sdd1'] '-v'])
else: self.assertEqual(args[0][8:], [
expected_args = [ '-l', '5',
'mdadm', '-e', 'default',
'-C', '/dev/md0', '-n', '3',
'-R', '/dev/sdb1', '/dev/sdc1', '/dev/sdd1'])
'-v', self.assertEqual(sorted(args[0][5:8]), sorted(['--chunk', '256', '--force']))
'--force', self.assertIn('--chunk 256', ' '.join(args[0][5:8]))
'--chunk', '256', self.assertEqual(kwargs, {'python_shell': False})
'-l', '5',
'-e', 'default',
'-n', '3',
'/dev/sdb1', '/dev/sdc1', '/dev/sdd1'
]
mock.assert_called_once_with(expected_args, python_shell=False)
def test_create_test_mode(self): def test_create_test_mode(self):
mock = MagicMock() mock = MagicMock()