Added a mocked test case for --log passing to pip install.

This commit is contained in:
Pedro Algarvio 2013-07-14 14:35:15 +01:00
parent 21698d187d
commit c582d721d9

View File

@ -219,6 +219,28 @@ class PipTestCase(TestCase):
runas=None, runas=None,
cwd=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__': if __name__ == '__main__':
from integration import run_tests from integration import run_tests