aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFu Jinhua <fu.jinhua@zte.com.cn>2018-08-21 05:45:24 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-21 05:45:24 +0000
commit25138298de52e917a6b6cb240deb4bc1116bfc6a (patch)
tree2f68b8a0ddb96f1c77cf2be49f79a3575cfcf7c3
parent42b141c8d12687409e8aad2e33a5238082d4ed23 (diff)
parent0219166703adf17e02a9d3194f69b55652f7ab9a (diff)
Merge "Ns descriptor related stuffs."
-rw-r--r--catalog/packages/tests/test_nsd.py60
-rw-r--r--catalog/packages/urls.py13
2 files changed, 67 insertions, 6 deletions
diff --git a/catalog/packages/tests/test_nsd.py b/catalog/packages/tests/test_nsd.py
new file mode 100644
index 00000000..a1b344c1
--- /dev/null
+++ b/catalog/packages/tests/test_nsd.py
@@ -0,0 +1,60 @@
+# Copyright 2017 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+from django.test import TestCase
+from rest_framework import status
+from rest_framework.test import APIClient
+
+
+class TestNsDescriptor(TestCase):
+ def setUp(self):
+ self.client = APIClient()
+
+ def tearDown(self):
+ pass
+
+ def test_nsd_create_normal(self):
+ reqest_data = {
+ 'userDefinedData': {
+ 'key1': 'value1',
+ 'key2': 'value2',
+ 'key3': 'value3',
+ }
+ }
+ expected_reponse_data = {
+ 'nsdOnboardingState': 'CREATED',
+ 'nsdOperationalState': 'DISABLED',
+ 'nsdUsageState': 'NOT_IN_USE',
+ 'userDefinedData': {
+ 'key1': 'value1',
+ 'key2': 'value2',
+ 'key3': 'value3',
+ },
+ '_links': None
+ }
+ response = self.client.post(
+ '/api/nsd/v1/ns_descriptors',
+ data=reqest_data,
+ format='json'
+ )
+ response.data.pop('id')
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED)
+ self.assertEqual(expected_reponse_data, response.data)
+
+ def test_nsd_content_upload_normal(self):
+ pass
+
+ def test_nsd_content_upload_failure(self):
+ pass
diff --git a/catalog/packages/urls.py b/catalog/packages/urls.py
index 4c37e052..466dba07 100644
--- a/catalog/packages/urls.py
+++ b/catalog/packages/urls.py
@@ -14,9 +14,8 @@
from django.conf.urls import url
-from catalog.packages.views import catalog_views
-# from catalog.packages.views.nsd_views import ns_descriptors, ns_info, nsd_content, pnf_descriptors, pnfd_info, pnfd_content, nsd_subscriptions, nsd_subscription
-# from catalog.packages.views.vnfpkg_views import vnf_packages, vnf_package, vnfd, package_content, upload_from_uri, vnfpkg_subscriptions, vnfpkg_subscription, artifacts
+from catalog.packages.views import catalog_views, ns_descriptor_views
+
urlpatterns = [
url(r'^api/catalog/v1/nspackages$', catalog_views.nspackages_rc, name='nspackages_rc'),
@@ -26,10 +25,12 @@ urlpatterns = [
url(r'^api/catalog/v1/parsernsd$', catalog_views.ns_model_parser, name='nsmodelparser_rc'),
url(r'^api/catalog/v1/parservnfd$', catalog_views.vnf_model_parser, name='vnfmodelparser_rc'),
+ # NSD
+ url(r'^api/nsd/v1/ns_descriptors$', ns_descriptor_views.create_ns_descriptors, name='ns_descriptors_rc'),
+ url(r'^api/nsd/v1/ns_descriptors$', ns_descriptor_views.query_ns_descriptors, name='ns_info_rd'),
+ # url(r'^api/nsd/v1/ns_descriptors/(?P<nsdInfoId>[0-9a-zA-Z\-\_]+)/nsd_content$', nsd_content_views.upload_nsd_content, name='nsd_content_ru'),
+
# TODO SOL005 & SOL003
- # url(r'^api/nsd/v1/ns_descriptors', ns_descriptors.as_view(), name='ns_descriptors_rc'),
- # url(r'^api/nsd/v1/ns_descriptors/(?P<nsdInfoId>[0-9a-zA-Z\-\_]+)$', ns_info.as_view(), name='ns_info_rd'),
- # url(r'^api/nsd/v1/ns_descriptors/(?P<nsdInfoId>[0-9a-zA-Z\-\_]+)$/nsd_content', nsd_content.as_view(), name='nsd_content_ru'),
# url(r'^api/nsd/v1/pnf_descriptors', pnf_descriptors.as_view(), name='pnf_descriptors_rc'),
# url(r'^api/nsd/v1/pnf_descriptors/(?P<pnfdInfoId>[0-9a-zA-Z\-\_]+)$', pnfd_info.as_view(), name='pnfd_info_rd'),
# url(r'^api/nsd/v1/pnf_descriptors/(?P<pnfdInfoId>[0-9a-zA-Z\-\_]+)$/pnfd_content', pnfd_content.as_view(), name='pnfd_content_ru'),