aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2016-12-01 01:05:28 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-12-01 01:05:28 +0000
commit322405412df26c8a0ee7f3a5aaa3b115950e97c8 (patch)
tree96cfafdb5d3d01625e2b4092a435c339bdfdb0d6 /tests/unit
parente12bcf0b3acdff1b483e0a7705c77acdee394c06 (diff)
parenta8db6ed817a39632bed19e0ece64f1862231db16 (diff)
Merge "ssh.py: add flag to keep stdin open"
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_ssh.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unit/test_ssh.py b/tests/unit/test_ssh.py
index a27052462..1e021a051 100644
--- a/tests/unit/test_ssh.py
+++ b/tests/unit/test_ssh.py
@@ -18,6 +18,8 @@
import os
import unittest
+from cStringIO import StringIO
+
import mock
from yardstick import ssh
@@ -275,6 +277,23 @@ class SSHRunTestCase(unittest.TestCase):
self.assertEqual(send_calls, self.fake_session.send.mock_calls)
@mock.patch("yardstick.ssh.select")
+ def test_run_stdin_keep_open(self, mock_select):
+ """Test run method with stdin.
+
+ Third send call was called with "e2" because only 3 bytes was sent
+ by second call. So remainig 2 bytes of "line2" was sent by third call.
+ """
+ mock_select.select.return_value = ([], [], [])
+ self.fake_session.exit_status_ready.side_effect = [0, 0, 0, True]
+ self.fake_session.send_ready.return_value = True
+ self.fake_session.send.side_effect = len
+ fake_stdin = StringIO("line1\nline2\n")
+ self.test_client.run("cmd", stdin=fake_stdin, keep_stdin_open=True)
+ call = mock.call
+ send_calls = [call("line1\nline2\n")]
+ self.assertEqual(send_calls, self.fake_session.send.mock_calls)
+
+ @mock.patch("yardstick.ssh.select")
def test_run_select_error(self, mock_select):
self.fake_session.exit_status_ready.return_value = False
mock_select.select.return_value = ([], [], [True])