mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Add unit tests for info_installed with all_versions
This commit is contained in:
parent
ae2ef507d6
commit
ea0e1a15a4
@ -611,3 +611,53 @@ class YumTestCase(TestCase, LoaderModuleMockMixin):
|
||||
'--exclude=kernel*', 'upgrade'],
|
||||
output_loglevel='trace',
|
||||
python_shell=False)
|
||||
|
||||
def test_info_installed_with_all_versions(self):
|
||||
'''
|
||||
Test the return information of all versions for the named package(s), installed on the system.
|
||||
|
||||
:return:
|
||||
'''
|
||||
run_out = {
|
||||
'virgo-dummy': [
|
||||
{'build_date': '2015-07-09T10:55:19Z',
|
||||
'vendor': 'openSUSE Build Service',
|
||||
'description': 'This is the Virgo dummy package used for testing SUSE Manager',
|
||||
'license': 'GPL-2.0', 'build_host': 'sheep05', 'url': 'http://www.suse.com',
|
||||
'build_date_time_t': 1436432119, 'relocations': '(not relocatable)',
|
||||
'source_rpm': 'virgo-dummy-1.0-1.1.src.rpm', 'install_date': '2016-02-23T16:31:57Z',
|
||||
'install_date_time_t': 1456241517, 'summary': 'Virgo dummy package', 'version': '1.0',
|
||||
'signature': 'DSA/SHA1, Thu Jul 9 08:55:33 2015, Key ID 27fa41bd8a7c64f9',
|
||||
'release': '1.1', 'group': 'Applications/System', 'arch': 'i686', 'size': '17992'},
|
||||
{'build_date': '2015-07-09T10:15:19Z',
|
||||
'vendor': 'openSUSE Build Service',
|
||||
'description': 'This is the Virgo dummy package used for testing SUSE Manager',
|
||||
'license': 'GPL-2.0', 'build_host': 'sheep05', 'url': 'http://www.suse.com',
|
||||
'build_date_time_t': 1436432119, 'relocations': '(not relocatable)',
|
||||
'source_rpm': 'virgo-dummy-1.0-1.1.src.rpm', 'install_date': '2016-02-23T16:31:57Z',
|
||||
'install_date_time_t': 14562415127, 'summary': 'Virgo dummy package', 'version': '1.0',
|
||||
'signature': 'DSA/SHA1, Thu Jul 9 08:55:33 2015, Key ID 27fa41bd8a7c64f9',
|
||||
'release': '1.1', 'group': 'Applications/System', 'arch': 'x86_64', 'size': '13124'}
|
||||
],
|
||||
'libopenssl1_0_0': [
|
||||
{'build_date': '2015-11-04T23:20:34Z', 'vendor': 'SUSE LLC <https://www.suse.com/>',
|
||||
'description': 'The OpenSSL Project is a collaborative effort.',
|
||||
'license': 'OpenSSL', 'build_host': 'sheep11', 'url': 'https://www.openssl.org/',
|
||||
'build_date_time_t': 1446675634, 'relocations': '(not relocatable)',
|
||||
'source_rpm': 'openssl-1.0.1i-34.1.src.rpm', 'install_date': '2016-02-23T16:31:35Z',
|
||||
'install_date_time_t': 1456241495, 'summary': 'Secure Sockets and Transport Layer Security',
|
||||
'version': '1.0.1i', 'signature': 'RSA/SHA256, Wed Nov 4 22:21:34 2015, Key ID 70af9e8139db7c82',
|
||||
'release': '34.1', 'group': 'Productivity/Networking/Security', 'packager': 'https://www.suse.com/',
|
||||
'arch': 'x86_64', 'size': '2576912'}
|
||||
]
|
||||
}
|
||||
with patch.dict(yumpkg.__salt__, {'lowpkg.info': MagicMock(return_value=run_out)}):
|
||||
installed = yumpkg.info_installed(all_versions=True)
|
||||
# Test overall products length
|
||||
self.assertEqual(len(installed), 2)
|
||||
|
||||
# Test multiple versions for the same package
|
||||
for pkg_name, pkg_info_list in installed.items():
|
||||
self.assertEqual(len(pkg_info_list), 2 if pkg_name == "virgo-dummy" else 1)
|
||||
for info in pkg_info_list:
|
||||
self.assertTrue(info['arch'] in ('x86_64', 'i686'))
|
||||
|
@ -327,6 +327,56 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
|
||||
installed = zypper.info_installed()
|
||||
self.assertEqual(installed['vīrgô']['description'], 'vīrgô d€šçripţiǫñ')
|
||||
|
||||
def test_info_installed_with_all_versions(self):
|
||||
'''
|
||||
Test the return information of all versions for the named package(s), installed on the system.
|
||||
|
||||
:return:
|
||||
'''
|
||||
run_out = {
|
||||
'virgo-dummy': [
|
||||
{'build_date': '2015-07-09T10:55:19Z',
|
||||
'vendor': 'openSUSE Build Service',
|
||||
'description': 'This is the Virgo dummy package used for testing SUSE Manager',
|
||||
'license': 'GPL-2.0', 'build_host': 'sheep05', 'url': 'http://www.suse.com',
|
||||
'build_date_time_t': 1436432119, 'relocations': '(not relocatable)',
|
||||
'source_rpm': 'virgo-dummy-1.0-1.1.src.rpm', 'install_date': '2016-02-23T16:31:57Z',
|
||||
'install_date_time_t': 1456241517, 'summary': 'Virgo dummy package', 'version': '1.0',
|
||||
'signature': 'DSA/SHA1, Thu Jul 9 08:55:33 2015, Key ID 27fa41bd8a7c64f9',
|
||||
'release': '1.1', 'group': 'Applications/System', 'arch': 'i686', 'size': '17992'},
|
||||
{'build_date': '2015-07-09T10:15:19Z',
|
||||
'vendor': 'openSUSE Build Service',
|
||||
'description': 'This is the Virgo dummy package used for testing SUSE Manager',
|
||||
'license': 'GPL-2.0', 'build_host': 'sheep05', 'url': 'http://www.suse.com',
|
||||
'build_date_time_t': 1436432119, 'relocations': '(not relocatable)',
|
||||
'source_rpm': 'virgo-dummy-1.0-1.1.src.rpm', 'install_date': '2016-02-23T16:31:57Z',
|
||||
'install_date_time_t': 14562415127, 'summary': 'Virgo dummy package', 'version': '1.0',
|
||||
'signature': 'DSA/SHA1, Thu Jul 9 08:55:33 2015, Key ID 27fa41bd8a7c64f9',
|
||||
'release': '1.1', 'group': 'Applications/System', 'arch': 'x86_64', 'size': '13124'}
|
||||
],
|
||||
'libopenssl1_0_0': [
|
||||
{'build_date': '2015-11-04T23:20:34Z', 'vendor': 'SUSE LLC <https://www.suse.com/>',
|
||||
'description': 'The OpenSSL Project is a collaborative effort.',
|
||||
'license': 'OpenSSL', 'build_host': 'sheep11', 'url': 'https://www.openssl.org/',
|
||||
'build_date_time_t': 1446675634, 'relocations': '(not relocatable)',
|
||||
'source_rpm': 'openssl-1.0.1i-34.1.src.rpm', 'install_date': '2016-02-23T16:31:35Z',
|
||||
'install_date_time_t': 1456241495, 'summary': 'Secure Sockets and Transport Layer Security',
|
||||
'version': '1.0.1i', 'signature': 'RSA/SHA256, Wed Nov 4 22:21:34 2015, Key ID 70af9e8139db7c82',
|
||||
'release': '34.1', 'group': 'Productivity/Networking/Security', 'packager': 'https://www.suse.com/',
|
||||
'arch': 'x86_64', 'size': '2576912'}
|
||||
]
|
||||
}
|
||||
with patch.dict(zypper.__salt__, {'lowpkg.info': MagicMock(return_value=run_out)}):
|
||||
installed = zypper.info_installed(all_versions=True)
|
||||
# Test overall products length
|
||||
self.assertEqual(len(installed), 2)
|
||||
|
||||
# Test multiple versions for the same package
|
||||
for pkg_name, pkg_info_list in installed.items():
|
||||
self.assertEqual(len(pkg_info_list), 2 if pkg_name == "virgo-dummy" else 1)
|
||||
for info in pkg_info_list:
|
||||
self.assertTrue(info['arch'] in ('x86_64', 'i686'))
|
||||
|
||||
def test_info_available(self):
|
||||
'''
|
||||
Test return the information of the named package available for the system.
|
||||
|
Loading…
Reference in New Issue
Block a user