Add UT cases for build-in workflow 21/27621/3
authorfujinhua <fu.jinhua@zte.com.cn>
Mon, 8 Jan 2018 07:32:58 +0000 (15:32 +0800)
committerfujinhua <fu.jinhua@zte.com.cn>
Mon, 8 Jan 2018 07:49:11 +0000 (15:49 +0800)
Add abnormal cases

Change-Id: I893098056dbc9375c14890932fe31dc9dc3c33fc
Issue-ID: VFC-653
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
lcm/workflows/tests.py

index 5a91db3..daf61fc 100644 (file)
@@ -137,3 +137,37 @@ class WorkflowViewTest(unittest.TestCase):
         mock_call_req.side_effect = side_effect
 
         self.assertTrue(build_in.run_ns_instantiate(wf_input))
+
+    @mock.patch.object(restcall, 'call_req')
+    def test_buildin_workflow_when_create_vl_failed(self, mock_call_req):
+        ns_inst_id = "1"
+        job_id = "1234"
+        wf_input = {
+            "jobId": job_id,
+            "nsInstanceId": ns_inst_id,
+            "object_context": '{"a": "b"}',
+            "object_additionalParamForNs": '{"c": "d"}',
+            "object_additionalParamForVnf": '{"e": "f"}',
+            "vlCount": 1,
+            "vnfCount": 1,
+            "sfcCount": 1,
+            "sdnControllerId": "2"
+        }
+        mock_vals = {
+            "api/nslcm/v1/ns/vls":
+                [0, json.JSONEncoder().encode({
+                    "result": "1",
+                    "detail": "vl1",
+                    "vlId": "1"
+                }), '201'],
+            "api/nslcm/v1/jobs/{jobId}".format(jobId=job_id):
+                [0, '{}', '201'],
+            "api/nslcm/v1/ns/{nsInstanceId}/postdeal".format(nsInstanceId=ns_inst_id):
+                [0, '{}', '201']
+        }
+
+        def side_effect(*args):
+            return mock_vals[args[4]]
+        mock_call_req.side_effect = side_effect
+
+        self.assertFalse(build_in.run_ns_instantiate(wf_input))