diff options
Diffstat (limited to 'app/test/fetch/cli_fetch')
-rw-r--r-- | app/test/fetch/cli_fetch/test_cli_access.py | 12 | ||||
-rw-r--r-- | app/test/fetch/cli_fetch/test_data/cli_access.py | 2 |
2 files changed, 5 insertions, 9 deletions
diff --git a/app/test/fetch/cli_fetch/test_cli_access.py b/app/test/fetch/cli_fetch/test_cli_access.py index be80619..d32e1ed 100644 --- a/app/test/fetch/cli_fetch/test_cli_access.py +++ b/app/test/fetch/cli_fetch/test_cli_access.py @@ -23,12 +23,10 @@ class TestCliAccess(TestFetch): self.configure_environment() self.cli_access = CliAccess() - @patch("utils.ssh_conn.SshConn.exec") def check_run_result(self, is_gateway_host, enable_cache, cached_command_result, exec_result, - expected_result, err_msg, - ssh_con_exec): + expected_result, err_msg): # mock cached commands if not is_gateway_host: self.cli_access.cached_commands = { @@ -38,17 +36,15 @@ class TestCliAccess(TestFetch): self.cli_access.cached_commands = { GATEWAY_CACHED_COMMAND: cached_command_result } - original_is_gateway_host = SshConn.is_gateway_host - SshConn.is_gateway_host = MagicMock(return_value=is_gateway_host) - ssh_con_exec.return_value = exec_result + + self.ssh_conn.exec.return_value = exec_result + self.ssh_conn.is_gateway_host.return_value = is_gateway_host result = self.cli_access.run(COMMAND, COMPUTE_HOST_ID, on_gateway=False, enable_cache=enable_cache) self.assertEqual(result, expected_result, err_msg) # reset the cached commands after testing self.cli_access.cached_commands = {} - # reset method - SshConn.is_gateway_host = original_is_gateway_host def test_run(self): curr_time = time.time() diff --git a/app/test/fetch/cli_fetch/test_data/cli_access.py b/app/test/fetch/cli_fetch/test_data/cli_access.py index b151dc6..03309d1 100644 --- a/app/test/fetch/cli_fetch/test_data/cli_access.py +++ b/app/test/fetch/cli_fetch/test_data/cli_access.py @@ -9,7 +9,7 @@ ############################################################################### COMPUTE_HOST_ID = "node-5.cisco.com" COMMAND = "virsh list" -NON_GATEWAY_CACHED_COMMAND = COMPUTE_HOST_ID + "," + "ssh -o StrictHostKeyChecking=no " + \ +NON_GATEWAY_CACHED_COMMAND = COMPUTE_HOST_ID + "," + "ssh -q -o StrictHostKeyChecking=no " + \ COMPUTE_HOST_ID + " sudo " + COMMAND GATEWAY_CACHED_COMMAND = COMPUTE_HOST_ID + "," + "sudo " + COMMAND CACHED_COMMAND_RESULT = " Id Name State\n---\n 2 instance-00000003 running" |