def test_call_command_invalid(self): """git_cache.command_execution.call_command(): Invalid command.""" return_code, stdout_buffer, stderr_buffer = call_command( "cmd_doesnt_exist") self.assertNotEqual(0, return_code) self.assertEqual(b'', stdout_buffer) self.assertIn(b'command not found', stderr_buffer)
def test_call_command_timeout(self): """git_cache.command_execution.call_command(): Command timeout.""" return_code, stdout_buffer, stderr_buffer = call_command( "sleep 2s", command_timeout=1) self.assertEqual(-1000, return_code) self.assertEqual(b'', stdout_buffer) self.assertEqual(b'', stderr_buffer)
def test_call_command_otimeout(self): """git_cache.command_execution.call_command(): Output timeout.""" return_code, stdout_buffer, stderr_buffer = call_command( "echo a; sleep 1s; echo b; sleep 3s; echo c", output_timeout=2) self.assertEqual(-2000, return_code) self.assertEqual(b'a\r\nb\r\n', stdout_buffer) self.assertEqual(b'', stderr_buffer)
def test_call_command_retcode(self): """git_cache.command_execution.call_command(): Correct return code.""" return_code, stdout_buffer, stderr_buffer = call_command("exit 12") self.assertEqual(12, return_code) self.assertEqual(b'', stdout_buffer) self.assertEqual(b'', stderr_buffer)
def test_call_command_valid(self): """git_cache.command_execution.call_command(): Valid command.""" return_code, stdout_buffer, stderr_buffer = call_command("true") self.assertEqual(0, return_code) self.assertEqual(b'', stdout_buffer) self.assertEqual(b'', stderr_buffer)