X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Ftests%2Funit%2Ftest_ssh.py;h=b727e821dd2894841c09d104f19cd99fad87a212;hb=305b69cc6b840ced701a09bca0435937dcb42723;hp=5cf1e50a0de320c17362cc2ba4189f922f2c7884;hpb=b935c3228523c30dacdaba551ecee3703ff78168;p=yardstick.git diff --git a/yardstick/tests/unit/test_ssh.py b/yardstick/tests/unit/test_ssh.py index 5cf1e50a0..b727e821d 100644 --- a/yardstick/tests/unit/test_ssh.py +++ b/yardstick/tests/unit/test_ssh.py @@ -238,6 +238,25 @@ class SSHTestCase(unittest.TestCase): self.assertEqual("stdout fake data", stdout) self.assertEqual("stderr fake data", stderr) + @mock.patch("yardstick.ssh.six.moves.StringIO") + def test_execute_raise_on_error_passed(self, mock_string_io): + mock_string_io.side_effect = stdio = [mock.Mock(), mock.Mock()] + stdio[0].read.return_value = "stdout fake data" + stdio[1].read.return_value = "stderr fake data" + with mock.patch.object(self.test_client, "run", return_value=0) \ + as mock_run: + status, stdout, stderr = self.test_client.execute( + "cmd", + stdin="fake_stdin", + timeout=43, + raise_on_error=True) + mock_run.assert_called_once_with( + "cmd", stdin="fake_stdin", stdout=stdio[0], + stderr=stdio[1], timeout=43, raise_on_error=True) + self.assertEqual(0, status) + self.assertEqual("stdout fake data", stdout) + self.assertEqual("stderr fake data", stderr) + @mock.patch("yardstick.ssh.time") def test_wait_timeout(self, mock_time): mock_time.time.side_effect = [1, 50, 150]