|
5 | 5 |
|
6 | 6 | # Import Python libs
|
7 | 7 | from __future__ import absolute_import, print_function, unicode_literals
|
| 8 | +import os |
8 | 9 |
|
9 | 10 | # Import Salt Testing Libs
|
10 | 11 | from tests.support.mixins import LoaderModuleMockMixin
|
@@ -99,3 +100,69 @@ def test_file_dict(self):
|
99 | 100 | 'stdout': 'Salt'})
|
100 | 101 | with patch.dict(dpkg.__salt__, {'cmd.run_all': mock}):
|
101 | 102 | self.assertEqual(dpkg.file_dict('httpd'), 'Error: error')
|
| 103 | + |
| 104 | + def test_info(self): |
| 105 | + ''' |
| 106 | + Test package info |
| 107 | + ''' |
| 108 | + mock = MagicMock(return_value={'retcode': 0, |
| 109 | + 'stderr': '', |
| 110 | + 'stdout': |
| 111 | + os.linesep.join([ |
| 112 | + 'package:bash', |
| 113 | + 'revision:', |
| 114 | + 'architecture:amd64', |
| 115 | + 'maintainer:Ubuntu Developers <[email protected]>', |
| 116 | + 'summary:', |
| 117 | + 'source:bash', |
| 118 | + 'version:4.4.18-2ubuntu1', |
| 119 | + 'section:shells', |
| 120 | + 'installed_size:1588', |
| 121 | + 'size:', |
| 122 | + 'MD5:', |
| 123 | + 'SHA1:', |
| 124 | + 'SHA256:', |
| 125 | + 'origin:', |
| 126 | + 'homepage:http://tiswww.case.edu/php/chet/bash/bashtop.html', |
| 127 | + 'status:ii ', |
| 128 | + '======', |
| 129 | + 'description:GNU Bourne Again SHell', |
| 130 | + ' Bash is an sh-compatible command language interpreter that executes', |
| 131 | + ' commands read from the standard input or from a file. Bash also', |
| 132 | + ' incorporates useful features from the Korn and C shells (ksh and csh).', |
| 133 | + ' .', |
| 134 | + ' Bash is ultimately intended to be a conformant implementation of the', |
| 135 | + ' IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2).', |
| 136 | + ' .', |
| 137 | + ' The Programmable Completion Code, by Ian Macdonald, is now found in', |
| 138 | + ' the bash-completion package.', |
| 139 | + '------' |
| 140 | + ])}) |
| 141 | + |
| 142 | + with patch.dict(dpkg.__salt__, {'cmd.run_all': mock}), \ |
| 143 | + patch.dict(dpkg.__grains__, {'os': 'Ubuntu', 'osrelease_info': (18, 4)}), \ |
| 144 | + patch('salt.utils.path.which', MagicMock(return_value=False)), \ |
| 145 | + patch('os.path.exists', MagicMock(return_value=False)),\ |
| 146 | + patch('os.path.getmtime', MagicMock(return_value=1560199259.0)): |
| 147 | + self.assertDictEqual(dpkg.info('bash'), |
| 148 | + {'bash': {'architecture': 'amd64', |
| 149 | + 'description': os.linesep.join([ |
| 150 | + 'GNU Bourne Again SHell', |
| 151 | + ' Bash is an sh-compatible command language interpreter that executes', |
| 152 | + ' commands read from the standard input or from a file. Bash also', |
| 153 | + ' incorporates useful features from the Korn and C shells (ksh and csh).', |
| 154 | + ' .', |
| 155 | + ' Bash is ultimately intended to be a conformant implementation of the', |
| 156 | + ' IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2).', |
| 157 | + ' .', |
| 158 | + ' The Programmable Completion Code, by Ian Macdonald, is now found in', |
| 159 | + ' the bash-completion package.' + os.linesep |
| 160 | + ]), |
| 161 | + 'homepage': 'http://tiswww.case.edu/php/chet/bash/bashtop.html', |
| 162 | + 'maintainer': 'Ubuntu Developers ' |
| 163 | + |
| 164 | + 'package': 'bash', |
| 165 | + 'section': 'shells', |
| 166 | + 'source': 'bash', |
| 167 | + 'status': 'ii', |
| 168 | + 'version': '4.4.18-2ubuntu1'}}) |
0 commit comments