diff options
author | Fu Jinhua <fu.jinhua@zte.com.cn> | 2018-08-27 01:01:42 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-27 01:01:42 +0000 |
commit | 691939f4214676edf41b396c7bcc3c4c934a3254 (patch) | |
tree | b12db8abe2453e9aa55a47f0704fb9efac0c424d | |
parent | 4ff593f61db3f0397ff790e0da6321e7ae43aa3e (diff) | |
parent | 7585dcf65d23e200a92aabc22a9db0f1065b66f0 (diff) |
Merge "Deal with nfPackage"
-rw-r--r-- | catalog/packages/biz/vnf_package.py | 11 | ||||
-rw-r--r-- | catalog/packages/tests/test_vnf_package.py | 33 |
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) |