diff options
author | 2017-09-23 10:05:38 +0800 | |
---|---|---|
committer | 2017-09-23 10:05:38 +0800 | |
commit | 28fc25c700e703774bffcab6b96ca9985173283d (patch) | |
tree | 97df18e464bdeb6434b6e08d85f315e078d11a6a | |
parent | 07acabebb3acdecd440987b2c3f377f08df6da3b (diff) |
Add catalog UT for vnfd parse
Change-Id: Ie2cd717d46f73b4bacc1b74b7814d24fd13f498c
Issue-Id: VFC-439
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | catalog/packages/tests/test_nf.py | 13 | ||||
-rw-r--r-- | catalog/packages/views.py | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/catalog/packages/tests/test_nf.py b/catalog/packages/tests/test_nf.py index fd2cc7db..657806ff 100644 --- a/catalog/packages/tests/test_nf.py +++ b/catalog/packages/tests/test_nf.py @@ -331,4 +331,15 @@ class TestNfPackage(TestCase): "csarName": "4.csar", "downloadUrl": "http://127.0.0.1:8806/static/catalog/4/4.csar" }, - "imageInfo": []}, resp.data)
\ No newline at end of file + "imageInfo": []}, resp.data) + + ############################################################################################################### + + @mock.patch.object(toscaparser, 'parse_vnfd') + def test_vnfd_parse_normal(self, mock_parse_vnfd): + VnfPackageModel(vnfPackageId="8", vnfdId="10").save() + mock_parse_vnfd.return_value = json.JSONEncoder().encode({"c": "d"}) + resp = self.client.post("/api/catalog/v1/parservnfd", + {"csarId": "8", "inputs": []}, format='json') + self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) + self.assertEqual({"model": '{"c": "d"}'}, resp.data) diff --git a/catalog/packages/views.py b/catalog/packages/views.py index 174b2388..a5922d3d 100644 --- a/catalog/packages/views.py +++ b/catalog/packages/views.py @@ -121,7 +121,7 @@ def vnf_model_parser(request, *args, **kwargs): csar_id = ignore_case_get(request.data, "csarId") inputs = ignore_case_get(request.data, "inputs") logger.debug("Enter %s, csar_id=%s, inputs=%s", fun_name(), csar_id, inputs) - nf_package.parse_vnfd(csar_id, inputs) + ret = nf_package.parse_vnfd(csar_id, inputs) logger.info("Leave %s, Return value is %s", fun_name(), ret) if ret[0] != 0: return Response(data={'error': ret[1]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) |