summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-10-16 10:58:49 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-10-16 11:12:32 +0800
commitc16d48b3ed60829a9636a073af06bd6301f17531 (patch)
tree0d706292bfbc5046c80bec85b33c8d993798e87f
parent4057cea12ba38ff273adefed097e164dfa2907e3 (diff)
Add default value for user defined data
Change-Id: I64d800014ec1adb87eaa7db6f70fc8f08fb4c347 Issue-ID: VFC-1151 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--catalog/packages/biz/ns_descriptor.py2
-rw-r--r--catalog/packages/biz/pnf_descriptor.py2
-rw-r--r--catalog/packages/biz/vnf_package.py2
-rw-r--r--catalog/packages/tests/test_ns_descriptor.py5
-rw-r--r--catalog/packages/tests/test_pnf_descriptor.py5
5 files changed, 3 insertions, 13 deletions
diff --git a/catalog/packages/biz/ns_descriptor.py b/catalog/packages/biz/ns_descriptor.py
index f625da6d..5741eaca 100644
--- a/catalog/packages/biz/ns_descriptor.py
+++ b/catalog/packages/biz/ns_descriptor.py
@@ -39,7 +39,7 @@ class NsDescriptor(object):
def create(self, data, id=None):
logger.info('Start to create a NSD...')
- user_defined_data = ignore_case_get(data, 'userDefinedData')
+ user_defined_data = ignore_case_get(data, 'userDefinedData', {})
data = {
'id': id if id else str(uuid.uuid4()),
'nsdOnboardingState': PKG_STATUS.CREATED,
diff --git a/catalog/packages/biz/pnf_descriptor.py b/catalog/packages/biz/pnf_descriptor.py
index 3910c44d..fe773447 100644
--- a/catalog/packages/biz/pnf_descriptor.py
+++ b/catalog/packages/biz/pnf_descriptor.py
@@ -36,7 +36,7 @@ class PnfDescriptor(object):
def create(self, data):
logger.info('Start to create a PNFD...')
- user_defined_data = ignore_case_get(data, 'userDefinedData')
+ user_defined_data = ignore_case_get(data, 'userDefinedData', {})
data = {
'id': str(uuid.uuid4()),
'pnfdOnboardingState': PKG_STATUS.CREATED,
diff --git a/catalog/packages/biz/vnf_package.py b/catalog/packages/biz/vnf_package.py
index 4f9c939e..0444e989 100644
--- a/catalog/packages/biz/vnf_package.py
+++ b/catalog/packages/biz/vnf_package.py
@@ -39,7 +39,7 @@ class VnfPackage(object):
pass
def create_vnf_pkg(self, data):
- user_defined_data = ignore_case_get(data, "userDefinedData")
+ user_defined_data = ignore_case_get(data, "userDefinedData", {})
vnf_pkg_id = str(uuid.uuid4())
VnfPackageModel.objects.create(
vnfPackageId=vnf_pkg_id,
diff --git a/catalog/packages/tests/test_ns_descriptor.py b/catalog/packages/tests/test_ns_descriptor.py
index 8ed04d01..3f8d245f 100644
--- a/catalog/packages/tests/test_ns_descriptor.py
+++ b/catalog/packages/tests/test_ns_descriptor.py
@@ -80,11 +80,6 @@ class TestNsDescriptor(TestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(expected_reponse_data, response.data)
- def test_nsd_create_failed(self):
- reqest_data = {'username': "111"}
- response = self.client.post('/api/nsd/v1/ns_descriptors', data=reqest_data, format='json')
- self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
-
def test_query_multiple_nsds_normal(self):
expected_reponse_data = [
copy.deepcopy(self.expected_nsd_info),
diff --git a/catalog/packages/tests/test_pnf_descriptor.py b/catalog/packages/tests/test_pnf_descriptor.py
index 7afdeae1..277676f7 100644
--- a/catalog/packages/tests/test_pnf_descriptor.py
+++ b/catalog/packages/tests/test_pnf_descriptor.py
@@ -75,11 +75,6 @@ class TestPnfDescriptor(TestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(expected_reponse_data, response.data)
- def test_pnfd_create_failed(self):
- request_data = {'username': "111"}
- response = self.client.post('/api/nsd/v1/pnf_descriptors', data=request_data, format='json')
- self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
-
def test_query_multiple_pnfds_normal(self):
expected_reponse_data = [
copy.deepcopy(self.expected_pnfd_info),