mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Enhances pkg.list_downloaded information of a package
This commit is contained in:
parent
bd1f170a05
commit
ddf98e3fe3
@ -926,7 +926,13 @@ def list_downloaded():
|
||||
for filename in fnmatch.filter(filenames, '*.rpm'):
|
||||
package_path = os.path.join(root, filename)
|
||||
pkg_info = __salt__['lowpkg.bin_pkg_info'](package_path)
|
||||
ret.setdefault(pkg_info['name'], {})[pkg_info['version']] = package_path
|
||||
pkg_timestamp = int(os.path.getctime(package_path))
|
||||
ret.setdefault(pkg_info['name'], {})[pkg_info['version']] = {
|
||||
'path': package_path,
|
||||
'size': os.path.getsize(package_path),
|
||||
'creation_date_time_t': pkg_timestamp,
|
||||
'creation_date_time': datetime.datetime.fromtimestamp(pkg_timestamp).isoformat(),
|
||||
}
|
||||
return ret
|
||||
|
||||
|
||||
|
@ -1798,7 +1798,13 @@ def list_downloaded():
|
||||
for filename in fnmatch.filter(filenames, '*.rpm'):
|
||||
package_path = os.path.join(root, filename)
|
||||
pkg_info = __salt__['lowpkg.bin_pkg_info'](package_path)
|
||||
ret.setdefault(pkg_info['name'], {})[pkg_info['version']] = package_path
|
||||
pkg_timestamp = int(os.path.getctime(package_path))
|
||||
ret.setdefault(pkg_info['name'], {})[pkg_info['version']] = {
|
||||
'path': package_path,
|
||||
'size': os.path.getsize(package_path),
|
||||
'creation_date_time_t': pkg_timestamp,
|
||||
'creation_date_time': datetime.datetime.fromtimestamp(pkg_timestamp).isoformat(),
|
||||
}
|
||||
return ret
|
||||
|
||||
|
||||
|
@ -504,6 +504,8 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
self.assertDictEqual(list_patches, PATCHES_RET)
|
||||
|
||||
@patch('os.walk', MagicMock(return_value=[('test', 'test', 'test')]))
|
||||
@patch('os.path.getsize', MagicMock(return_value=123456))
|
||||
@patch('os.path.getmtime', MagicMock(return_value=1234567890.123456))
|
||||
@patch('fnmatch.filter', MagicMock(return_value=['/var/cache/zypper/packages/foo/bar/test_package.rpm']))
|
||||
def test_list_downloaded(self):
|
||||
'''
|
||||
@ -513,7 +515,11 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
'''
|
||||
DOWNLOADED_RET = {
|
||||
'test-package': {
|
||||
'1.0': '/var/cache/zypper/packages/foo/bar/test_package.rpm'
|
||||
'1.0': {
|
||||
'path': '/var/cache/zypper/packages/foo/bar/test_package.rpm',
|
||||
'size': 123456,
|
||||
'timestamp': 1234567890.123456,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -548,7 +554,7 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
self.assertEqual(zypper.download("nmap", "foo"), test_out)
|
||||
|
||||
@patch('salt.modules.zypper._systemd_scope', MagicMock(return_value=False))
|
||||
@patch('salt.modules.zypper.list_downloaded', MagicMock(side_effect=[{}, {'vim': {'1.1': '/foo/bar/test.rpm'}}]))
|
||||
@patch('salt.modules.zypper.list_downloaded', MagicMock(side_effect=[{}, {'vim': {'1.1': {'path': '/foo/bar/test.rpm', 'size': 1234, 'timestamp': 1234567890}}}]))
|
||||
def test_install_with_downloadonly(self):
|
||||
'''
|
||||
Test a package installation with downloadonly=True.
|
||||
@ -566,10 +572,10 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
'--download-only',
|
||||
'vim'
|
||||
)
|
||||
self.assertDictEqual(ret, {'vim': {'new': {'1.1': '/foo/bar/test.rpm'}, 'old': ''}})
|
||||
self.assertDictEqual(ret, {'vim': {'new': {'1.1': {'path': '/foo/bar/test.rpm', 'size': 1234, 'timestamp': 1234567890}}, 'old': ''}})
|
||||
|
||||
@patch('salt.modules.zypper._systemd_scope', MagicMock(return_value=False))
|
||||
@patch('salt.modules.zypper.list_downloaded', MagicMock(return_value={'vim': {'1.1': '/foo/bar/test.rpm'}}))
|
||||
@patch('salt.modules.zypper.list_downloaded', MagicMock(return_value={'vim': {'1.1': {'path': '/foo/bar/test.rpm', 'size': 1234, 'timestamp': 1234567890}}}))
|
||||
def test_install_with_downloadonly_already_downloaded(self):
|
||||
'''
|
||||
Test a package installation with downloadonly=True when package is already downloaded.
|
||||
|
Loading…
Reference in New Issue
Block a user