Add unit test for ns create
[vfc/nfvo/lcm.git] / lcm / ns / tests / test_ns_create.py
index e462e1c..73ea278 100644 (file)
@@ -70,11 +70,23 @@ class TestNsInstantiate(TestCase):
         mock_do_biz.side_effect = NSLCMException("nsd not exists.")
         new_nsd_id = '1'
         data = {
-            'nsdid': new_nsd_id,
-            'nsname': 'ns',
+            'csarId': new_nsd_id,
+            'nsName': 'ns',
             'description': 'description'
         }
         response = self.client.post("/api/nslcm/v1/ns", data=data)
         self.assertEqual(response.data["error"], "nsd not exists.")
         self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
         self.assertIn("error", response.data)
+
+    @mock.patch.object(restcall, 'call_req')
+    def test_create_ns_when_nsdid_not_exist(self, mock_call_req):
+        mock_call_req.return_value = [1, "Failed to get nsd.", '500']
+        data = {
+            'csarId': '1',
+            'nsName': 'ns',
+            'description': 'description'
+        }
+        response = self.client.post("/api/nslcm/v1/ns", data=data)
+        self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
+        self.assertIn("error", response.data)