Add UT cases for nsd parse 63/14763/1
authorfujinhua <fu.jinhua@zte.com.cn>
Sat, 23 Sep 2017 01:40:41 +0000 (09:40 +0800)
committerfujinhua <fu.jinhua@zte.com.cn>
Sat, 23 Sep 2017 01:40:41 +0000 (09:40 +0800)
Change-Id: I1147e4491d876896a7c1d82880c29c9b4924822e
Issue-id: VFC-437
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
catalog/packages/tests/test_ns.py

index de4555e..605679f 100644 (file)
@@ -482,6 +482,21 @@ class TestNsPackage(TestCase):
                 "downloadUrl": "http://127.0.0.1:8806/static/catalog/14/14.csar"
             }}, resp.data)
 
+    ###############################################################################################################
+
+    @mock.patch.object(toscaparser, 'parse_nsd')
+    def test_nsd_parse(self, mock_parse_nsd):
+        NSPackageModel(nsPackageId="18", nsdId="12").save()
+        mock_parse_nsd.return_value = json.JSONEncoder().encode({"a": "b"})
+        resp = self.client.post("/api/catalog/v1/parsernsd", 
+            {"csarId": "18", "inputs": []}, format='json')
+        self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED)
+        self.assertEqual({"model": '{"a": "b"}'}, resp.data)
+
+
+
+
+