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

This commit is contained in:
Pedro Algarvio 2013-07-14 14:38:57 +01:00
parent c582d721d9
commit 3372034c07

View File

@ -241,6 +241,37 @@ class PipTestCase(TestCase):
log='/tmp/pip-install.log'
)
def test_timeout_argument_in_resulting_command(self):
# Passing an int
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
with patch.dict(pip.__salt__, {'cmd.run_all': mock}):
pip.install('pep8', timeout=10)
mock.assert_called_once_with(
'pip install --timeout=10 pep8',
runas=None,
cwd=None
)
# Passing an int as a string
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
with patch.dict(pip.__salt__, {'cmd.run_all': mock}):
pip.install('pep8', timeout='10')
mock.assert_called_once_with(
'pip install --timeout=10 pep8',
runas=None,
cwd=None
)
# Passing a non-int to timeout
mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
with patch.dict(pip.__salt__, {'cmd.run_all': mock}):
self.assertRaises(
ValueError,
pip.install,
'pep8',
timeout='a'
)
if __name__ == '__main__':
from integration import run_tests