diff options
-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): |