summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbiancunkang <bian.cunkang@zte.com.cn>2018-08-24 19:29:44 +0800
committerFu Jinhua <fu.jinhua@zte.com.cn>2018-08-27 00:56:03 +0000
commit7585dcf65d23e200a92aabc22a9db0f1065b66f0 (patch)
treeb12db8abe2453e9aa55a47f0704fb9efac0c424d
parenta87814ef485c7233a8cc4b345c3efcef0a69973c (diff)
Deal with nfPackage
Add a test Change-Id: Ie8400b2429e4785e52b2e3bc9a4eb2650c844462 Issue-ID: VFC-1038 Signed-off-by: biancunkang <bian.cunkang@zte.com.cn>
-rw-r--r--catalog/packages/biz/vnf_package.py11
-rw-r--r--catalog/packages/tests/test_vnf_package.py33
2 files changed, 38 insertions, 6 deletions
diff --git a/catalog/packages/biz/vnf_package.py b/catalog/packages/biz/vnf_package.py
index d601e696..d63df9ae 100644
--- a/catalog/packages/biz/vnf_package.py
+++ b/catalog/packages/biz/vnf_package.py
@@ -70,18 +70,17 @@ def query_single(vnf_pkg_id):
raise CatalogException('VNF package(%s) does not exist.' % vnf_pkg_id)
pkg_info["id"] = nf_pkg[0].vnfPackageId
pkg_info["vnfdId"] = nf_pkg[0].vnfdId
- pkg_info["vnfdProvider"] = nf_pkg[0].vnfVendor
pkg_info["vnfProductName"] = nf_pkg[0].vnfdProductName
pkg_info["vnfSoftwareVersion"] = nf_pkg[0].vnfSoftwareVersion
pkg_info["vnfdVersion"] = nf_pkg[0].vnfdVersion
- pkg_info["checksum"] = nf_pkg[0].checksum
- pkg_info["softwareImages"] = "" # TODO
- pkg_info["additionalArtifacts"] = "" # TODO
+ pkg_info["checksum"] = json.JSONDecoder().decode(nf_pkg[0].checksum)
+ pkg_info["softwareImages"] = None # TODO
+ pkg_info["additionalArtifacts"] = None # TODO
pkg_info["onboardingState"] = nf_pkg[0].onboardingState
pkg_info["operationalState"] = nf_pkg[0].operationalState
pkg_info["usageState"] = nf_pkg[0].usageState
- pkg_info["userDefinedData"] = nf_pkg[0].userDefinedData
- pkg_info["_links"] = "" # TODO
+ pkg_info["userDefinedData"] = json.JSONDecoder().decode(nf_pkg[0].userDefinedData)
+ pkg_info["_links"] = None # TODO
return pkg_info
diff --git a/catalog/packages/tests/test_vnf_package.py b/catalog/packages/tests/test_vnf_package.py
index 7191ba87..cf49b89d 100644
--- a/catalog/packages/tests/test_vnf_package.py
+++ b/catalog/packages/tests/test_vnf_package.py
@@ -295,3 +295,36 @@ class TestVnfPackage(TestCase):
}
self.assertEqual(expect_resp_data, resp_data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
+
+ def test_query_single_vnf(self):
+ VnfPackageModel.objects.create(
+ vnfPackageId="222",
+ vnfdId="zte-hss-1.0",
+ vnfVendor="zte",
+ vnfdProductName="hss",
+ vnfSoftwareVersion="1.0.0",
+ vnfdVersion="1.0.0",
+ checksum='{"algorithm":"111", "hash": "11"}',
+ onboardingState="CREATED",
+ operationalState="DISABLED",
+ usageState="NOT_IN_USE",
+ userDefinedData='{"a": "A"}'
+ )
+ response = self.client.get("/api/vnfpkgm/v1/vnf_packages/222")
+ expect_data = {
+ "id": "222",
+ "vnfdId": "zte-hss-1.0",
+ "vnfProductName": "hss",
+ "vnfSoftwareVersion": "1.0.0",
+ "vnfdVersion": "1.0.0",
+ "checksum": {"algorithm": "111", "hash": "11"},
+ "softwareImages": None,
+ "additionalArtifacts": None,
+ "onboardingState": "CREATED",
+ "operationalState": "DISABLED",
+ "usageState": "NOT_IN_USE",
+ "userDefinedData": {"a": "A"},
+ "_links": None
+ }
+ self.assertEqual(response.data, expect_data)
+ self.assertEqual(response.status_code, status.HTTP_200_OK)