def test_proxy_config_error(self): """ UT: nxos module:proxy_config method - CommandExecutionError """ with patch( "salt.proxy.nxos._sendline_ssh", autospec=True, side_effect=CommandExecutionError, ): with self.assertRaises(CommandExecutionError): nxos_proxy.proxy_config("show version", save_config=True)
def test_proxy_config_save_config(self): """ UT: nxos module:proxy_config method - ssh success path """ commands = ["feature bgp", "router bgp 65535"] with patch("salt.proxy.nxos.DEVICE_DETAILS", {"save_config": None}): with patch("salt.proxy.nxos._sendline_ssh", autospec=True) as sendline_ssh: result = nxos_proxy.proxy_config(commands, save_config=True) self.assertEqual(result, [commands, sendline_ssh.return_value])
def test_proxy_config(self): """ UT: nxos module:proxy_config method - nxapi success path""" commands = ["feature bgp", "router bgp 65535"] with patch("salt.proxy.nxos.DEVICE_DETAILS", {"save_config": False}): with patch("salt.proxy.nxos._nxapi_request", autospec=True) as nxapi_request: result = nxos_proxy.proxy_config(commands) self.assertEqual(result, [commands, nxapi_request.return_value])