summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-01-08 16:05:55 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-01-08 16:05:55 +0800
commite0ed4f97a865118ec8447b0657edc9a93fd5cc2d (patch)
tree0a255717bf7cfe3bfb75789a512658f953969db3
parentd30bc2ccdd0556382a83e40983bfbee1ac2796c8 (diff)
Add UT cases for build-in workflow
Add abnormal cases Change-Id: I61049cbdd7f879ffe8427aa07a7b5c259b092343 Issue-ID: VFC-653 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/workflows/tests.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/lcm/workflows/tests.py b/lcm/workflows/tests.py
index daf61fcf..53a4a628 100644
--- a/lcm/workflows/tests.py
+++ b/lcm/workflows/tests.py
@@ -171,3 +171,52 @@ class WorkflowViewTest(unittest.TestCase):
mock_call_req.side_effect = side_effect
self.assertFalse(build_in.run_ns_instantiate(wf_input))
+
+ @mock.patch.object(restcall, 'call_req')
+ def test_buildin_workflow_when_create_vnf_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": "0",
+ "detail": "vl1",
+ "vlId": "1"
+ }), '201'],
+ "api/nslcm/v1/ns/vnfs":
+ [0, json.JSONEncoder().encode({
+ "vnfInstId": "2",
+ "jobId": "11"
+ }), '201'],
+ "api/nslcm/v1/ns/vnfs/2":
+ [0, json.JSONEncoder().encode({
+ "vnfStatus": "error"
+ }), '201'],
+ "/api/nslcm/v1/jobs/11?responseId=0":
+ [0, json.JSONEncoder().encode({"responseDescriptor": {
+ "responseId": "1",
+ "progress": 100,
+ "statusDescription": "ok"
+ }}), '200'],
+ "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))