diff options
author | 2018-06-13 10:15:49 +0800 | |
---|---|---|
committer | 2018-06-13 10:15:49 +0800 | |
commit | fe23fe497db5aab58dff966575b6c79928fbb842 (patch) | |
tree | 52b0da9dd4c32ffff47f9e181f2001bb7ce0597f /vio | |
parent | afd19e309b2a9361627704c51c385770f4bc3aaa (diff) |
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 <ethanlynnl@vmware.com>
Diffstat (limited to 'vio')
-rw-r--r-- | vio/vio/tests/test_restcall.py | 13 |
1 files changed, 13 insertions, 0 deletions
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) |