diff options
author | fengyuanxing <feng.yuanxing@zte.com.cn> | 2018-03-06 16:38:35 +0800 |
---|---|---|
committer | fengyuanxing <feng.yuanxing@zte.com.cn> | 2018-03-06 16:52:59 +0800 |
commit | fd7f7cca09ff55cb7e816dbbebc360f8f248825f (patch) | |
tree | e7abdb8ce3d70dbed5601855d6c5f3d3ef1af341 | |
parent | 2f113b19f3271933a230cc759264fc204672b49e (diff) |
Modify test case after refactoring code
Change-Id: Ib75192fce294e1c190efa0e327c88d60e19bf8f7
Issue-ID: VFC-784
Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
-rw-r--r-- | lcm/pub/tests/test_scaleaspect.py | 43 | ||||
-rw-r--r-- | lcm/pub/utils/scaleaspect.py | 1 |
2 files changed, 44 insertions, 0 deletions
diff --git a/lcm/pub/tests/test_scaleaspect.py b/lcm/pub/tests/test_scaleaspect.py index 81cfb9cb..7cfe3be6 100644 --- a/lcm/pub/tests/test_scaleaspect.py +++ b/lcm/pub/tests/test_scaleaspect.py @@ -1,10 +1,15 @@ from django.test import TestCase from lcm.pub.utils.scaleaspect import get_json_data from lcm.pub.utils.scaleaspect import get_nsdId +from lcm.pub.utils.scaleaspect import get_scale_vnf_data_from_json +from lcm.pub.utils.scaleaspect import get_scale_vnf_data_info_list +from lcm.pub.utils.scaleaspect import set_scacle_vnf_instance_id from lcm.pub.database.models import NfInstModel from lcm.pub.database.models import NSInstModel +from lcm.pub.msapi import catalog from lcm.pub.utils.timeutil import now_time import os +import mock class TestScaleAspect(TestCase): @@ -101,6 +106,44 @@ class TestScaleAspect(TestCase): NSInstModel().clean() NfInstModel().clean() + def test_get_scale_vnf_data_from_json(self): + vnf_data_package = get_scale_vnf_data_from_json( + self.scaling_map_json, "23", "TIC_EDGE_IMS", "1") + self.assertIsNotNone(vnf_data_package) + self.assertEqual(2, vnf_data_package.__len__()) + + @mock.patch.object(catalog, 'get_scalingmap_json_package') + def test_get_scale_vnf_data_info_list( + self, mock_get_scalingmap_json_package): + mock_get_scalingmap_json_package.return_value = self.scaling_map_json + + scale_vnf_data = get_scale_vnf_data_info_list(self.scaleNsData, "1") + self.assertIsNotNone(scale_vnf_data) + self.assertEqual(2, scale_vnf_data.__len__()) + + def test_set_scacle_vnf_instance_id(self): + vnf_scale_info_list = [ + { + "vnfd_id": "nf_zte_cscf", + "vnf_scaleAspectId": "mpu", + "numberOfSteps": "1" + }, + { + "vnfd_id": "nf_zte_hss", + "vnf_scaleAspectId": "mpu", + "numberOfSteps": "1" + } + ] + result = set_scacle_vnf_instance_id(vnf_scale_info_list) + self.assertEqual(result[0]["numberOfSteps"], vnf_scale_info_list[0]["numberOfSteps"]) + self.assertEqual(result[0]["vnf_scaleAspectId"], vnf_scale_info_list[0]["vnf_scaleAspectId"]) + self.assertEqual(result[1]["numberOfSteps"], vnf_scale_info_list[0]["numberOfSteps"]) + self.assertEqual(result[1]["vnf_scaleAspectId"], vnf_scale_info_list[0]["vnf_scaleAspectId"]) + self.assertEqual("231", result[0]["vnfInstanceId"]) + self.assertEqual("232", result[1]["vnfInstanceId"]) + self.assertNotIn("vnfd_id", result[0]) + self.assertNotIn("vnfd_id", result[1]) + def test_get_nsdId(self): nsd_id = get_nsdId("1") self.assertEqual("23", nsd_id) diff --git a/lcm/pub/utils/scaleaspect.py b/lcm/pub/utils/scaleaspect.py index 70077740..e642ab01 100644 --- a/lcm/pub/utils/scaleaspect.py +++ b/lcm/pub/utils/scaleaspect.py @@ -230,6 +230,7 @@ def set_scacle_vnf_instance_id(vnf_scale_info_list): return scale_vnf_data_info_list +# Sets the scaling type of vnf data info list. def set_scaleVnfData_type(vnf_scale_list, scale_type): logger.debug( "vnf_scale_list = %s, type = %s" % |