Add a new test case with incorrect input 81/35081/1
authorfengyuanxing <feng.yuanxing@zte.com.cn>
Mon, 12 Mar 2018 02:45:31 +0000 (10:45 +0800)
committerfengyuanxing <feng.yuanxing@zte.com.cn>
Mon, 12 Mar 2018 02:45:31 +0000 (10:45 +0800)
Change-Id: Id98f0e1dedf903a8f11bd5a1c6b299d63ad24cb5
Issue-ID: VFC-784
Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
lcm/ns/tests/test_ns_manual_scale.py

index 157f50e..c977ff6 100644 (file)
@@ -21,7 +21,7 @@ from rest_framework import status
 
 from lcm.ns.const import NS_INST_STATUS
 from lcm.ns.ns_manual_scale import NSManualScaleService
-from lcm.pub.database.models import NSInstModel
+from lcm.pub.database.models import NSInstModel, JobModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils import restcall
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
@@ -110,12 +110,12 @@ class TestNsManualScale(TestCase):
         self.ns_inst_id = str(uuid.uuid4())
         self.job_id = JobUtil.create_job(
             "NS", JOB_TYPE.MANUAL_SCALE_VNF, self.ns_inst_id)
-
+        self.package_id = "7"
         self.client = Client()
         NSInstModel(
             id=self.ns_inst_id,
             name="abc",
-            nspackage_id="7",
+            nspackage_id=self.package_id,
             nsd_id="111").save()
 
     def tearDown(self):
@@ -138,6 +138,21 @@ class TestNsManualScale(TestCase):
             self.ns_inst_id, data=data)
         self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
 
+    def test_ns_manual_scale_error_scaletype(self):
+        data = {
+            "scaleType": "SCALE_ERR",
+            "scaleNsData": [{
+                "scaleNsByStepsData": [{
+                    "aspectId": "sss_zte",
+                    "numberOfSteps": 1,
+                    "scalingDirection": "0"
+                }]
+            }]
+        }
+        NSManualScaleService(self.ns_inst_id, data, self.job_id).run()
+        jobs = JobModel.objects.filter(jobid=self.job_id)
+        self.assertEqual(255, jobs[0].progress)
+
     @mock.patch.object(restcall, 'call_req')
     def test_ns_manual_scale_thread(self, mock_call):
         data = {