From fe23fe497db5aab58dff966575b6c79928fbb842 Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Wed, 13 Jun 2018 10:15:49 +0800 Subject: Add test_call_req_response_not_ready Add test_call_req_response_not_ready Change-Id: I6aa47a7420d7e6df3980500b9de58e8d0d3b8d06 Issue-ID: MULTICLOUD-199 Signed-off-by: Ethan Lynn --- vio/vio/tests/test_restcall.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'vio') diff --git a/vio/vio/tests/test_restcall.py b/vio/vio/tests/test_restcall.py index 08e38a9..3cb22ca 100644 --- a/vio/vio/tests/test_restcall.py +++ b/vio/vio/tests/test_restcall.py @@ -76,3 +76,16 @@ class TestRestCall(unittest.TestCase): ret = restcall.call_req("http://onap.org/", "user", "pass", restcall.rest_no_auth, "vim", "GET") self.assertEqual(expect_ret, ret) + + @mock.patch("traceback.format_exc") + @mock.patch("sys.exc_info") + @mock.patch("httplib2.Http.request") + def test_call_req_response_not_ready(self, mock_req, mock_sys, + mock_traceback): + mock_sys.return_value = "httplib.ResponseNotReady" + mock_req.side_effect = [Exception("httplib.ResponseNotReady")] * 3 + expect_ret = [1, "Unable to connect to http://onap.org/vim", "", ""] + ret = restcall.call_req("http://onap.org/", "user", "pass", + restcall.rest_no_auth, "vim", "GET") + self.assertEqual(expect_ret, ret) + self.assertEqual(3, mock_req.call_count) -- cgit 1.2.3-korg