def test_sendline_invalid_method(self): """UT: nxos module:sendline method - invalid method""" command = "show version" method = "invalid" # Execute the function under test result = nxos_module.sendline(command, method) self.assertIn("INPUT ERROR", result)
def test_sendline_valid_method_proxy(self): """ UT: nxos module:sendline method - valid method over proxy """ command = "show version" method = "cli_show_ascii" with patch("salt.utils.platform.is_proxy", return_value=True, autospec=True): nxos_module.__proxy__["nxos.sendline"].return_value = n9k_show_ver result = nxos_module.sendline(command, method) self.assertIn(n9k_show_ver, result)
def test_sendline_valid_method_nxapi_uds(self): """ UT: nxos module:sendline method - valid method over nxapi uds """ command = "show version" method = "cli_show_ascii" with patch("salt.utils.platform.is_proxy", MagicMock(return_value=False)): with patch( "salt.modules.nxos._nxapi_request", return_value=n9k_show_ver, autospec=True, ): result = nxos_module.sendline(command, method) self.assertIn(n9k_show_ver, result)