Merge pull request #39058 from sergeizv/fix-lvm-fullversion

Fix salt.modules.linux_lvm.fullversion
This commit is contained in:
Mike Place 2017-01-31 12:01:12 -07:00 committed by GitHub
commit 86b4b77bfe
2 changed files with 16 additions and 5 deletions

View File

@ -56,7 +56,7 @@ def fullversion():
out = __salt__['cmd.run'](cmd).splitlines()
for line in out:
comps = line.split(':')
ret[comps[0].strip()] = comps[1].strip()
ret[comps[0].strip()] = comps[1].strip()
return ret

View File

@ -34,18 +34,29 @@ class LinuxLVMTestCase(TestCase):
'''
Tests LVM version info from lvm version
'''
mock = MagicMock(return_value='Library version : 1')
mock = MagicMock(return_value=
' LVM version: 2.02.168(2) (2016-11-30)\n'
' Library version: 1.03.01 (2016-11-30)\n'
' Driver version: 4.35.0\n'
)
with patch.dict(linux_lvm.__salt__, {'cmd.run': mock}):
self.assertEqual(linux_lvm.version(), '1')
self.assertEqual(linux_lvm.version(), '2.02.168(2) (2016-11-30)')
def test_fullversion(self):
'''
Tests all version info from lvm version
'''
mock = MagicMock(return_value='Library version : 1')
mock = MagicMock(return_value=
' LVM version: 2.02.168(2) (2016-11-30)\n'
' Library version: 1.03.01 (2016-11-30)\n'
' Driver version: 4.35.0\n'
)
with patch.dict(linux_lvm.__salt__, {'cmd.run': mock}):
self.assertDictEqual(linux_lvm.fullversion(),
{'Library version': '1'})
{'LVM version': '2.02.168(2) (2016-11-30)',
'Library version': '1.03.01 (2016-11-30)',
'Driver version': '4.35.0',
})
def test_pvdisplay(self):
'''