mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Added a mocked test case for --log
passing to pip install
.
This commit is contained in:
parent
21698d187d
commit
c582d721d9
@ -219,6 +219,28 @@ class PipTestCase(TestCase):
|
||||
runas=None,
|
||||
cwd=None)
|
||||
|
||||
@patch('os.path')
|
||||
def test_log_argument_in_resulting_command(self, mock_path):
|
||||
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
||||
with patch.dict(pip.__salt__, {'cmd.run_all': mock}):
|
||||
pip.install('pep8', log='/tmp/pip-install.log')
|
||||
mock.assert_called_once_with(
|
||||
'pip install --log=/tmp/pip-install.log pep8',
|
||||
runas=None,
|
||||
cwd=None
|
||||
)
|
||||
|
||||
# Let's fake a non-writable log file
|
||||
mock_path.exists.side_effect = IOError('Fooo!')
|
||||
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
||||
with patch.dict(pip.__salt__, {'cmd.run_all': mock}):
|
||||
self.assertRaises(
|
||||
IOError,
|
||||
pip.install,
|
||||
'pep8',
|
||||
log='/tmp/pip-install.log'
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
Loading…
Reference in New Issue
Block a user