Пример #1
0
 def test_run_executable_with_stream(self):
     with mock.patch('kb_python.utils.logger.debug') as debug_mock:
         utils.run_executable(['echo', 'TEST'], stream=True)
         debug_mock.assert_has_calls([call('TEST')])
Пример #2
0
 def test_run_executable_no_wait(self):
     with mock.patch('kb_python.utils.sp') as sp_mock:
         sp_mock.Popen().returncode = 0
         utils.run_executable(['echo', 'TEST'], wait=False)
         sp_mock.Popen().poll.assert_not_called()
Пример #3
0
 def test_run_exectuable_with_returncode(self):
     utils.run_executable(['bash', 'nonexistent option'], returncode=127)
Пример #4
0
 def test_run_exectuable_raises_exception(self):
     with self.assertRaises(sp.SubprocessError):
         utils.run_executable(['bash', 'nonexistent option'])
Пример #5
0
 def test_run_executable(self):
     with mock.patch('kb_python.utils.STATS') as STATS:
         p = utils.run_executable(['echo', 'TEST'], stream=False)
         self.assertEqual(p.stdout.read(), 'TEST\n')
         STATS.command.assert_called_once_with(['echo', 'TEST'],
                                               runtime=ANY)
Пример #6
0
 def test_run_executable(self):
     p = utils.run_executable(['echo', 'TEST'], stream=False)
     self.assertEqual(p.stdout.read(), 'TEST\n')