improve code coverage rate (scale vnf to level) after vfclcm upgraded from python2... 99/91799/2
authorhongyuzhao <zhao.hongyu@zte.com.cn>
Mon, 22 Jul 2019 09:34:47 +0000 (17:34 +0800)
committermaopeng zhang <zhang.maopeng1@zte.com.cn>
Mon, 22 Jul 2019 10:33:23 +0000 (10:33 +0000)
Change-Id: I5a6141591bdc639c2508a38af206bc5c45f8d309
Issue-ID: VFC-1429
Signed-off-by: hongyuzhao <zhao.hongyu@zte.com.cn>
lcm/lcm/jobs/views.py
lcm/lcm/nf/tests/const.py
lcm/lcm/nf/tests/test_scale_vnf.py
lcm/lcm/nf/tests/test_scale_vnf_to_level.py
lcm/lcm/nf/views/subscriptions_view.py

index 7221bf5..02b7687 100644 (file)
@@ -50,7 +50,7 @@ class JobView(APIView):
             resp_serializer = JobQueryRespSerializer(data=ret)
             if not resp_serializer.is_valid():
                 raise NFLCMException(resp_serializer.errors)
-            return Response(data=resp_serializer.data, status=status.HTTP_200_OK)
+            return Response(data=ret, status=status.HTTP_200_OK)
         except Exception as e:
             logger.error(traceback.format_exc())
             return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
index c950951..8a50fa1 100644 (file)
@@ -1166,7 +1166,22 @@ multiple_vnf_lcm_op = [{
 #     }
 # }
 vnfd_for_scale = {
-    "volume_storages": [],
+    "volume_storages": [
+        {
+            "volume_storage_id": "test",
+            "properties": {
+                "location_info": {
+                    "vimid": "vim_1",
+                    "tenant": "chinamobile",
+                    "availability_zone": "test",
+                },
+                "volume_name": "test",
+                "custom_volume_type": "test",
+                "size_of_storage": "\"10 GB\"",
+            },
+            "image_file": "test",
+        },
+    ],
     "vnf": {
         "type": "tosca.nodes.nfv.VNF",
         "requirements": {
@@ -1202,7 +1217,16 @@ vnfd_for_scale = {
         {
             "description": "",
             "virtual_storages": [
-
+                {
+                    "virtual_storage_id": "test",
+                    "type_of_storage": "ephemeral",
+                    "size_of_storage": "10 GB",
+                }
+            ],
+            "volume_storages": [
+                {
+                    "volume_storage_id": "test",
+                }
             ],
             "vdu_id": "sunshine",
             "artifacts": [
@@ -1222,11 +1246,6 @@ vnfd_for_scale = {
                 "virtual_memory": {
                     "virtual_mem_size": "4096 MB"
                 },
-                "virtual_local_storage": [
-                    {
-                        "size_of_storage": "40 GB"
-                    }
-                ]
             },
             "vls": [
 
index 4361403..c415bf0 100644 (file)
@@ -91,7 +91,7 @@ class TestNfScale(TestCase):
     def test_scale_out_vnf_success(self, mock_call, mock_call_req):
         self.nf_inst_id = '6789'
         res_cache = {"volume": {}, "flavor": {}, "port": {}}
-        # res_cache["volume"]["volume_storage1"] = "vol1"
+        res_cache["volume"]["test"] = "test"
         # res_cache["flavor"]["vdu1Id"] = "flavor1"
         res_cache["port"]["ext_cp"] = "port1"
         NfInstModel(nfinstid=self.nf_inst_id,
@@ -193,6 +193,7 @@ class TestNfScale(TestCase):
         ).run()
 
         NfInstModel.objects.filter(nfinstid=self.nf_inst_id).delete()
+        # print([{job.progress: job.descp} for job in  JobStatusModel.objects.filter( jobid=self.job_id)])
         self.assert_job_result(
             self.job_id,
             100,
index 173f539..23d812c 100644 (file)
@@ -91,6 +91,7 @@ class TestNfScaleToLevel(TestCase):
     def test_scale_out_vnf_success(self, mock_call, mock_call_req):
         self.nf_inst_id = '6789'
         res_cache = {"volume": {}, "flavor": {}, "port": {}}
+        res_cache["volume"]["test"] = "test"
         res_cache["port"]["ext_cp"] = "port1"
         NfInstModel(nfinstid=self.nf_inst_id,
                     nf_name='VNF1',
index 547e012..4f6566b 100644 (file)
@@ -106,7 +106,7 @@ class SubscriptionsView(APIView):
             raise NFLCMException(subscriptions_serializer.errors)\r
 \r
         logger.debug("SubscribeNotification--get::> Remove default fields")\r
-        return Response(data=subscriptions_serializer.data, status=status.HTTP_200_OK)\r
+        return Response(data=resp_data, status=status.HTTP_200_OK)\r
 \r
 \r
 class SubscriptionDetailView(APIView):\r