X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=multivimbroker%2Fmultivimbroker%2Ftests%2Ftest_check_capacity.py;h=d7a7caef232b77e779cc29eba4063687af9ee21d;hb=refs%2Fchanges%2F11%2F40311%2F1;hp=63fc7dcc6583c58bdd0af0bf52268e1da90e0a13;hpb=df7f13c5cfe0cf047d35775f11ac3a363e65ef1a;p=multicloud%2Fframework.git diff --git a/multivimbroker/multivimbroker/tests/test_check_capacity.py b/multivimbroker/multivimbroker/tests/test_check_capacity.py index 63fc7dc..d7a7cae 100644 --- a/multivimbroker/multivimbroker/tests/test_check_capacity.py +++ b/multivimbroker/multivimbroker/tests/test_check_capacity.py @@ -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) @@ -78,3 +78,16 @@ class CheckCapacityTest(unittest.TestCase): } self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertDictEqual(expect_body, resp.data) + + def test_check_capacity_invalid_input(self): + req = mock.Mock() + req.body = "hello world" + req.get_full_path.return_value = ("http://msb.onap.org/api/multicloud" + "/v0/check_vim_capacity") + expect_body = { + "error": ("Invalidate request body " + "No JSON object could be decoded.") + } + resp = self.view.post(req) + self.assertEqual(status.HTTP_400_BAD_REQUEST, resp.status_code) + self.assertDictEqual(expect_body, resp.data)