3 ##############################################################################
4 # Copyright (c) 2016 Kanglin Yin and others
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Unittest for yardstick.benchmark.scenarios.availability.utils
17 from yardstick.benchmark.scenarios.availability import util
19 @mock.patch('yardstick.benchmark.scenarios.availability.util.subprocess')
20 class ExecuteShellTestCase(unittest.TestCase):
22 def test__fun_execute_shell_command_successful(self, mock_subprocess):
24 mock_subprocess.check_output.return_value = (0, 'unittest')
25 exitcode, output = util.execute_shell_command(cmd)
26 self.assertEqual(exitcode, 0)
28 def test__fun_execute_shell_command_fail_cmd_exception(self, mock_subprocess):
30 mock_subprocess.check_output.side_effect = RuntimeError
31 exitcode, output = util.execute_shell_command(cmd)
32 self.assertEqual(exitcode, -1)