From 1a41a12dfae60165635a8b442e84042280ed79d7 Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Wed, 13 Jun 2018 10:20:27 +0800 Subject: Add test_call_req_url_err Add test_call_req_url_err Change-Id: Ic4ee391b8c065b8b35690b55faf6d5d3f90ee192 Issue-ID: MULTICLOUD-199 Signed-off-by: Ethan Lynn --- vio/vio/tests/test_restcall.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vio/vio/tests/test_restcall.py b/vio/vio/tests/test_restcall.py index 3cb22ca..b04aec1 100644 --- a/vio/vio/tests/test_restcall.py +++ b/vio/vio/tests/test_restcall.py @@ -10,6 +10,7 @@ import mock import unittest +import urllib2 from vio.pub.utils import restcall @@ -89,3 +90,12 @@ class TestRestCall(unittest.TestCase): restcall.rest_no_auth, "vim", "GET") self.assertEqual(expect_ret, ret) self.assertEqual(3, mock_req.call_count) + + @mock.patch("httplib2.Http.request") + def test_call_req_url_err(self, mock_req): + urlerr = urllib2.URLError("urlerror") + mock_req.side_effect = [urlerr] + expect_ret = [2, str(urlerr), "", ""] + ret = restcall.call_req("http://onap.org/", "user", "pass", + restcall.rest_no_auth, "vim", "GET") + self.assertEqual(expect_ret, ret) -- cgit 1.2.3-korg