adds unit test for ssh_remote.replace_remote_line

Adding unit test for the new method added to
search a line by string and replace the old line
with a new line

Change-Id: I95d71bafebd9d0a4fea499813135fac06d152ab6
Story: #2003176
Task: #26708
This commit is contained in:
bhujay 2018-09-25 19:40:08 +05:30
parent b03b5ebbe8
commit 4e39a45f45
1 changed files with 17 additions and 1 deletions

View File

@ -451,10 +451,26 @@ class TestInstanceInteropHelper(base.SaharaTestCase):
@mock.patch('sahara.utils.ssh_remote.InstanceInteropHelper._run_s')
@mock.patch('sahara.utils.ssh_remote.InstanceInteropHelper._log_command')
def test_execute_on_vm_interactive(self, p_log_command, p_run_s):
def test_replace_remote_line(self, p_log_command, p_run_s):
instance = FakeInstance('inst13', '123',
'10.0.0.13', '10.0.0.13', 'user13', 'key13')
remote = ssh_remote.InstanceInteropHelper(instance)
description = ('In file "file" replacing line begining with string'
'"str" with "newline"')
remote.replace_remote_line("file", "str", "newline")
p_run_s.assert_called_once_with(ssh_remote._replace_remote_line,
None, description, "file", "str",
"newline")
p_log_command.assert_called_with(description)
@mock.patch('sahara.utils.ssh_remote.InstanceInteropHelper._run_s')
@mock.patch('sahara.utils.ssh_remote.InstanceInteropHelper._log_command')
def test_execute_on_vm_interactive(self, p_log_command, p_run_s):
instance = FakeInstance('inst14', '123',
'10.0.0.14', '10.0.0.14', 'user14', 'key14')
remote = ssh_remote.InstanceInteropHelper(instance)
description = 'Executing interactively "factor 42"'
remote.execute_on_vm_interactive("factor 42", None)