mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Add lowpkg tests for version comparison
This commit is contained in:
parent
afdf451d87
commit
f07c7ea792
@ -95,6 +95,28 @@ class RpmTestCase(TestCase):
|
||||
self.assertDictEqual(rpm.owner('/usr/bin/python', '/usr/bin/vim'),
|
||||
ret)
|
||||
|
||||
@patch('salt.modules.rpm.HAS_RPM', True)
|
||||
def test_version_cmp_rpm(self):
|
||||
'''
|
||||
Test package version is called RPM version if RPM-Python is installed
|
||||
|
||||
:return:
|
||||
'''
|
||||
rpm.rpm = MagicMock(return_value=MagicMock)
|
||||
with patch('salt.modules.rpm.rpm.labelCompare', MagicMock(return_value=0)):
|
||||
self.assertEqual(0, rpm.version_cmp('1', '2')) # mock returns 0, which means RPM was called
|
||||
|
||||
|
||||
@patch('salt.modules.rpm.HAS_RPM', False)
|
||||
def test_version_cmp_fallback(self):
|
||||
'''
|
||||
Test package version is called RPM version if RPM-Python is installed
|
||||
|
||||
:return:
|
||||
'''
|
||||
rpm.rpm = MagicMock(return_value=MagicMock)
|
||||
with patch('salt.modules.rpm.rpm.labelCompare', MagicMock(return_value=0)):
|
||||
self.assertEqual(-1, rpm.version_cmp('1', '2')) # mock returns -1, a python implementation was called
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
Loading…
Reference in New Issue
Block a user