summaryrefslogtreecommitdiffstats
path: root/vio
diff options
context:
space:
mode:
authorEthan Lynn <ethanlynnl@vmware.com>2018-10-30 08:48:48 +0800
committerEthan Lynn <ethanlynnl@vmware.com>2018-10-30 09:16:55 +0800
commit43f42d2d02ea875563e4d8cee171bdb5c070e7f2 (patch)
treec148ecefdaded489dce6eef734433c2850a0cd85 /vio
parent364ea7094f35cd9ad4438a97ea5f1421ba9dc34d (diff)
Add UT for cloud intent registration
Add unit test for cloud intent registration, fix failure cause by new flake8 Change-Id: I155fb11b33895e972a78ba991de30416c63900e5 Issue-ID: MULTICLOUD-388 Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
Diffstat (limited to 'vio')
-rw-r--r--vio/vio/api_v2/api_router/controller_builder.py2
-rw-r--r--vio/vio/pub/utils/restcall.py2
-rw-r--r--vio/vio/swagger/views/flavor/views.py2
-rw-r--r--vio/vio/swagger/views/image/views.py6
-rw-r--r--vio/vio/swagger/views/network/views.py2
-rw-r--r--vio/vio/swagger/views/port/views.py2
-rw-r--r--vio/vio/swagger/views/server/views.py4
-rw-r--r--vio/vio/swagger/views/subnet/views.py2
-rw-r--r--vio/vio/swagger/views/volume/views.py2
-rw-r--r--vio/vio/swagger/views/workload/views.py2
-rw-r--r--vio/vio/tests/test_aai_client.py4
11 files changed, 16 insertions, 14 deletions
diff --git a/vio/vio/api_v2/api_router/controller_builder.py b/vio/vio/api_v2/api_router/controller_builder.py
index f910aaf..ae082a0 100644
--- a/vio/vio/api_v2/api_router/controller_builder.py
+++ b/vio/vio/api_v2/api_router/controller_builder.py
@@ -23,7 +23,7 @@ from vio.pub import exceptions
from vio.pub.msapi import extsys
-OBJ_IN_ARRAY = "(\w+)\[(\d+)\]\.(\w+)"
+OBJ_IN_ARRAY = r"(\w+)\[(\d+)\]\.(\w+)"
def _get_vim_auth_session(vim_id, tenant_id):
diff --git a/vio/vio/pub/utils/restcall.py b/vio/vio/pub/utils/restcall.py
index 1fed20e..a3b9a06 100644
--- a/vio/vio/pub/utils/restcall.py
+++ b/vio/vio/pub/utils/restcall.py
@@ -85,7 +85,7 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content='',
raise ex
except urllib2.URLError as err:
ret = [2, str(err), resp_status, resp]
- except Exception as ex:
+ except Exception:
logger.error(traceback.format_exc())
logger.error("[%s]ret=%s" % (callid, str(sys.exc_info())))
res_info = str(sys.exc_info())
diff --git a/vio/vio/swagger/views/flavor/views.py b/vio/vio/swagger/views/flavor/views.py
index 4e871b7..67aadb5 100644
--- a/vio/vio/swagger/views/flavor/views.py
+++ b/vio/vio/swagger/views/flavor/views.py
@@ -26,7 +26,7 @@ class FlavorsView(APIView):
def post(self, request, vimid, tenantid):
try:
create_req = json.loads(request.body)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
diff --git a/vio/vio/swagger/views/image/views.py b/vio/vio/swagger/views/image/views.py
index 6df6710..09f68eb 100644
--- a/vio/vio/swagger/views/image/views.py
+++ b/vio/vio/swagger/views/image/views.py
@@ -130,7 +130,7 @@ class CreateListImagesView(APIView):
try:
req_body = json.loads(request.body)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
vim_rsp = image_utils.vim_formatter(vim_info, tenantid)
@@ -246,14 +246,14 @@ class GetImageFileView(APIView):
try:
req_body = json.loads(request.body)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
vim_rsp = image_utils.vim_formatter(vim_info, tenantid)
image_instance = OperateImage.OperateImage(vim_info)
try:
image = image_instance.find_vim_image(imageid)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'the image does not exist'},
status=status.HTTP_404_NOT_FOUND)
diff --git a/vio/vio/swagger/views/network/views.py b/vio/vio/swagger/views/network/views.py
index 6d182e2..06e3a3f 100644
--- a/vio/vio/swagger/views/network/views.py
+++ b/vio/vio/swagger/views/network/views.py
@@ -30,7 +30,7 @@ class CreateNetworkView(APIView):
net = OperateNetwork.OperateNetwork()
try:
body = json.loads(request.body)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
try:
diff --git a/vio/vio/swagger/views/port/views.py b/vio/vio/swagger/views/port/views.py
index 33d633d..81b3f6a 100644
--- a/vio/vio/swagger/views/port/views.py
+++ b/vio/vio/swagger/views/port/views.py
@@ -30,7 +30,7 @@ class CreatePortView(APIView):
port = OperatePort.OperatePort()
try:
body = json.loads(request.body)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
try:
diff --git a/vio/vio/swagger/views/server/views.py b/vio/vio/swagger/views/server/views.py
index eb8acf0..710e461 100644
--- a/vio/vio/swagger/views/server/views.py
+++ b/vio/vio/swagger/views/server/views.py
@@ -29,7 +29,7 @@ class ListServersView(APIView):
def post(self, request, vimid, tenantid):
try:
create_req = json.loads(request.body)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -196,7 +196,7 @@ class ServerActionView(APIView):
def post(self, request, vimid, tenantid, serverid):
try:
action_req = json.loads(request.body)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
diff --git a/vio/vio/swagger/views/subnet/views.py b/vio/vio/swagger/views/subnet/views.py
index c8c412c..8fd0deb 100644
--- a/vio/vio/swagger/views/subnet/views.py
+++ b/vio/vio/swagger/views/subnet/views.py
@@ -30,7 +30,7 @@ class CreateSubnetView(APIView):
subnet = OperateSubnet.OperateSubnet()
try:
body = json.loads(request.body)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
try:
diff --git a/vio/vio/swagger/views/volume/views.py b/vio/vio/swagger/views/volume/views.py
index 6ebf624..0162474 100644
--- a/vio/vio/swagger/views/volume/views.py
+++ b/vio/vio/swagger/views/volume/views.py
@@ -123,7 +123,7 @@ class CreateListVolumeView(APIView):
volume_op = OperateVolume.OperateVolume(vim_info)
try:
body = json.loads(request.body)
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
try:
diff --git a/vio/vio/swagger/views/workload/views.py b/vio/vio/swagger/views/workload/views.py
index 17b5223..efcc2f7 100644
--- a/vio/vio/swagger/views/workload/views.py
+++ b/vio/vio/swagger/views/workload/views.py
@@ -64,7 +64,7 @@ class CreateStackViewV1(APIView):
status=status.HTTP_400_BAD_REQUEST)
body = handle_directives(body)
stack_body = body['template_data']
- except Exception as e:
+ except Exception:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
diff --git a/vio/vio/tests/test_aai_client.py b/vio/vio/tests/test_aai_client.py
index fa83d5d..ad66f40 100644
--- a/vio/vio/tests/test_aai_client.py
+++ b/vio/vio/tests/test_aai_client.py
@@ -249,6 +249,8 @@ class TestAAIClient(unittest.TestCase):
def test_get_hpa(self, mock_call):
self.view._get_hpa_basic_capabilities = mock.MagicMock()
self.view._get_hpa_basic_capabilities.return_value = {"hpa": "basic"}
+ self.view._get_intent_capabilities = mock.MagicMock()
+ self.view._get_intent_capabilities.return_value = {"hpa": "basic"}
self.view._get_cpupinning_capabilities = mock.MagicMock()
self.view._get_cpupinning_capabilities.return_value = {"hpa": "basic"}
self.view._get_cputopology_capabilities = mock.MagicMock()
@@ -268,7 +270,7 @@ class TestAAIClient(unittest.TestCase):
self.view._get_ovsdpdk_capabilities = mock.MagicMock()
self.view._get_ovsdpdk_capabilities.return_value = {"hpa": "basic"}
ret = self.view._get_hpa_capabilities({"extra_specs": {}})
- self.assertEqual([{"hpa": "basic"}]*9, ret)
+ self.assertEqual([{"hpa": "basic"}]*10, ret)
@mock.patch.object(restcall, "call_req")
def test_get_hpa_basic(self, mock_call):