diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-12-13 09:53:49 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-12-13 09:53:49 +0800 |
commit | cd4d2051800ca99f298b96068fb4e5ba095e15f9 (patch) | |
tree | a925f18211d4e2173dff7e4fc2453251257ffdc8 | |
parent | a70251aef3c34db92869dba2643c398a395ca418 (diff) |
Fix code and interface inconsistencies
Modify query all ns csars code and Interface inconsistencies
Change-Id: I72d4bf6c64723327e934087fa44fd70d6f1c8b30
Issue-ID: VFC-616
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | catalog/packages/ns_package.py | 10 | ||||
-rw-r--r-- | catalog/packages/tests/test_ns.py | 36 |
2 files changed, 30 insertions, 16 deletions
diff --git a/catalog/packages/ns_package.py b/catalog/packages/ns_package.py index c29e549f..cf1f2cd5 100644 --- a/catalog/packages/ns_package.py +++ b/catalog/packages/ns_package.py @@ -158,15 +158,11 @@ class NsPackage(object): return [0, "Delete CSAR(%s) successfully." % csar_id] def get_csars(self): - csars = {"csars": []} + csars = [] nss = NSPackageModel.objects.filter() for ns in nss: - csars["csars"].append({ - "csarId": ns.nsPackageId, - "nsdId": ns.nsdId, - "nsdProvider": ns.nsdDesginer, - "nsdVersion": ns.nsdVersion - }) + ret = self.get_csar(ns.nsPackageId) + csars.append(ret[1]) return [0, csars] def get_csar(self, csar_id): diff --git a/catalog/packages/tests/test_ns.py b/catalog/packages/tests/test_ns.py index d4c6ce99..9f0f2acc 100644 --- a/catalog/packages/tests/test_ns.py +++ b/catalog/packages/tests/test_ns.py @@ -461,20 +461,38 @@ class TestNsPackage(TestCase): self.assertEqual("Delete CSAR(8) successfully.", resp.data["statusDescription"]) def test_ns_pkg_get_all(self): - NSPackageModel(nsPackageId="13", nsdId="2", nsdDesginer="3", nsdVersion="4").save() - + NSPackageModel(nsPackageId="13", nsdId="2", nsdDesginer="2", nsdVersion="2", + nsPackageUri="13.csar", nsdModel="").save() + NSPackageModel(nsPackageId="14", nsdId="3", nsdDesginer="3", nsdVersion="3", + nsPackageUri="14.csar", nsdModel="").save() resp = self.client.get("/api/catalog/v1/nspackages") self.assertEqual(resp.status_code, status.HTTP_200_OK) - expect_data = { - "csars": [ - { - "csarId": "13", + expect_data = [ + { + "csarId": "13", + "packageInfo": { + "csarName": "13.csar", + "nsdProvider": "2", "nsdId": "2", + "nsPackageId": "13", + "downloadUrl": "http://127.0.0.1:8806/static/catalog/13/13.csar", + "nsdModel": "", + "nsdVersion": "2" + } + }, + { + "csarId": "14", + "packageInfo": { + "csarName": "14.csar", "nsdProvider": "3", - "nsdVersion": "4" + "nsdId": "3", + "nsPackageId": "14", + "downloadUrl": "http://127.0.0.1:8806/static/catalog/14/14.csar", + "nsdModel": "", + "nsdVersion": "3" } - ] - } + } + ] self.assertEqual(expect_data, resp.data) def test_ns_pkg_get_one(self): |