summaryrefslogtreecommitdiffstats
path: root/vio
diff options
context:
space:
mode:
Diffstat (limited to 'vio')
-rw-r--r--vio/vio/swagger/views/capacity/views.py2
-rw-r--r--vio/vio/tests/test_capacity_view.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/vio/vio/swagger/views/capacity/views.py b/vio/vio/swagger/views/capacity/views.py
index ce5d854..1fdc481 100644
--- a/vio/vio/swagger/views/capacity/views.py
+++ b/vio/vio/swagger/views/capacity/views.py
@@ -72,7 +72,7 @@ class CapacityCheck(APIView):
def post(self, request, vimid):
try:
requirement = json.loads(request.body)
- except json.JSONDecodeError as ex:
+ except ValueError as ex:
return Response(data={'error': str(ex)},
status=status.HTTP_400_BAD_REQUEST)
try:
diff --git a/vio/vio/tests/test_capacity_view.py b/vio/vio/tests/test_capacity_view.py
index 174d73e..d27efba 100644
--- a/vio/vio/tests/test_capacity_view.py
+++ b/vio/vio/tests/test_capacity_view.py
@@ -102,3 +102,10 @@ class CapacityCheckTest(unittest.TestCase):
resp = self.view.post(req, "openstack_regionone")
self.assertEqual(status.HTTP_200_OK, resp.status_code)
self.assertEqual({"result": False}, resp.data)
+
+ def test_check_capacity_invalid_input(self):
+ req = mock.Mock()
+ req.body = "hello world"
+
+ resp = self.view.post(req, "openstack_regionone")
+ self.assertEqual(status.HTTP_400_BAD_REQUEST, resp.status_code)