def test_nxapi_request_proxy(self): """UT: nxos module:_nxapi_request method - proxy""" with patch("salt.utils.platform.is_proxy", autospec=True, return_value=True): mock_request = create_autospec(nxos_utils.nxapi_request, return_value="router_data") with patch.dict(nxos_module.__proxy__, {"nxos._nxapi_request": mock_request}): result = nxos_module._nxapi_request("show version") self.assertEqual(result, "router_data")
def test_nxapi_request_no_proxy(self): """UT: nxos module:_nxapi_request method - no proxy""" with patch("salt.utils.platform.is_proxy", autospec=True, return_value=False): mock_cmd = MagicMock(return_value={"nxos": {"save_config": False}}) with patch.dict(nxos_module.__salt__, {"config.get": mock_cmd}): mock_request = create_autospec(nxos_utils.nxapi_request) with patch.dict(nxos_module.__utils__, {"nxos.nxapi_request": mock_request}): result = nxos_module._nxapi_request("show version") self.assertEqual(result, mock_request.return_value) mock_request.assert_called_with("show version", "cli_conf", **mock_cmd.return_value)