From: laili Date: Tue, 21 Aug 2018 11:28:46 +0000 (+0800) Subject: Ns descriptor related stuffs. X-Git-Tag: 1.2.0~117 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F49%2F61549%2F3;p=vfc%2Fnfvo%2Fcatalog.git Ns descriptor related stuffs. Add a urlpattern. Add a test to the creation of pnfd. Change-Id: I3b320db4d9b1f2f0cf0208590494bbf30b7b6289 Issue-ID: VFC-1037 Signed-off-by: laili --- diff --git a/catalog/packages/tests/test_pnfd.py b/catalog/packages/tests/test_pnfd.py new file mode 100644 index 00000000..4d8e8603 --- /dev/null +++ b/catalog/packages/tests/test_pnfd.py @@ -0,0 +1,59 @@ +# 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 TestPnfDescriptor(TestCase): + def setUp(self): + self.client = APIClient() + + def tearDown(self): + pass + + def test_pnfd_create_normal(self): + reqest_data = { + 'userDefinedData': { + 'key1': 'value1', + 'key2': 'value2', + 'key3': 'value3', + } + } + expected_reponse_data = { + 'pnfdOnboardingState': 'CREATED', + 'pnfdUsageState': 'NOT_IN_USE', + 'userDefinedData': { + 'key1': 'value1', + 'key2': 'value2', + 'key3': 'value3', + }, + '_links': None + } + response = self.client.post( + '/api/nsd/v1/pnf_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_pnfd_content_upload_normal(self): + pass + + def test_pnfd_content_upload_failure(self): + pass diff --git a/catalog/packages/urls.py b/catalog/packages/urls.py index a3b4f0fe..9c8d3d66 100644 --- a/catalog/packages/urls.py +++ b/catalog/packages/urls.py @@ -14,8 +14,8 @@ from django.conf.urls import url -from catalog.packages.views import catalog_views, ns_descriptor_views, nsd_content_views from catalog.packages.views.vnfpkg_views import package_content +from catalog.packages.views import catalog_views, ns_descriptor_views, nsd_content_views, pnf_descriptor_views urlpatterns = [ @@ -31,8 +31,10 @@ urlpatterns = [ 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[0-9a-zA-Z\-\_]+)/nsd_content$', nsd_content_views.upload_nsd_content, name='nsd_content_ru'), + # PNF + url(r'^api/nsd/v1/pnf_descriptors', pnf_descriptor_views.create_pnf_descriptors, name='pnf_descriptors_rc'), # TODO SOL005 & SOL003 - # url(r'^api/nsd/v1/pnf_descriptors', pnf_descriptors.as_view(), name='pnf_descriptors_rc'), + # url(r'^api/nsd/v1/pnf_descriptors/(?P[0-9a-zA-Z\-\_]+)$', pnfd_info.as_view(), name='pnfd_info_rd'), # url(r'^api/nsd/v1/pnf_descriptors/(?P[0-9a-zA-Z\-\_]+)$/pnfd_content', pnfd_content.as_view(), name='pnfd_content_ru'), # url(r'^api/nsd/v1/subscriptions', nsd_subscriptions.as_view(), name='subscriptions_rc'),