add test for create ns if no csar id 47/93747/1
authoryangyan <yangyanyj@chinamobile.com>
Mon, 19 Aug 2019 06:57:19 +0000 (14:57 +0800)
committeryangyan <yangyanyj@chinamobile.com>
Mon, 19 Aug 2019 06:57:25 +0000 (14:57 +0800)
Change-Id: I0ffa704fe9454b95a1e9485e997ce17b587ba342
Issue-ID: VFC-1489
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
lcm/ns/tests/test_ns_create.py

index ef00a6e..7531c8d 100644 (file)
@@ -80,3 +80,10 @@ class TestNsInstantiate(TestCase):
         response = self.client.post("/api/nslcm/v1/ns", data=self.create_ns_dict, format='json')
         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_ns_csar_no_exist(self, mock_call_req):
+        mock_call_req.return_value = [1, "Failed query ns csar file", 500]
+        response = self.client.post("/api/nslcm/v1/ns", data={"csarId": ''}, format='json')
+        self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
+        self.assertIn("error", response.data)