Merge "Fix check_vim_capacity"
authorLiang Ke <lokyse@163.com>
Fri, 30 Mar 2018 01:58:43 +0000 (01:58 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 30 Mar 2018 01:58:43 +0000 (01:58 +0000)
multivimbroker/multivimbroker/forwarder/views.py
multivimbroker/multivimbroker/tests/test_check_capacity.py

index c66a6f1..4f6e6ef 100644 (file)
@@ -113,11 +113,11 @@ class CheckCapacity(BaseServer):
         for vim in body.get("VIMs", []):
             url = request.get_full_path().replace(
                 "check_vim_capacity", "%s/capacity_check" % vim)
-            resp = self.send(vim, url, newbody, "POST")
-            if resp.status_code != status.HTTP_200_OK:
+            resp = self.send(vim, url, str(newbody), "POST")
+            if int(resp.status_code) != status.HTTP_200_OK:
                 continue
             try:
-                resp_body = json.loads(resp.body)
+                resp_body = json.loads(resp.content)
             except ValueError:
                 continue
             if not resp_body.get("result", False):
index 60035e0..d7a7cae 100644 (file)
@@ -40,10 +40,10 @@ class CheckCapacityTest(unittest.TestCase):
                                           "/v0/check_vim_capacity")
         with mock.patch.object(self.view, "send") as send:
             plugin_resp = mock.Mock()
-            plugin_resp.body = """{
+            plugin_resp.content = """{
                 "result": true
             }"""
-            plugin_resp.status_code = status.HTTP_200_OK
+            plugin_resp.status_code = str(status.HTTP_200_OK)
             send.return_value = plugin_resp
 
             resp = self.view.post(req)
@@ -66,10 +66,10 @@ class CheckCapacityTest(unittest.TestCase):
                                           "/v0/check_vim_capacity")
         with mock.patch.object(self.view, "send") as send:
             plugin_resp = mock.Mock()
-            plugin_resp.body = """{
+            plugin_resp.content = """{
                 "result": false
             }"""
-            plugin_resp.status_code = status.HTTP_200_OK
+            plugin_resp.status_code = str(status.HTTP_200_OK)
             send.return_value = plugin_resp
 
             resp = self.view.post(req)