-# Copyright 2017 ZTE Corporation.
+# Copyright 2018 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# See the License for the specific language governing permissions and
# limitations under the License.
+
+import json
import os
from django.test import TestCase
from rest_framework import status
from rest_framework.test import APIClient
+from catalog.pub.database.models import PnfPackageModel
class TestPnfDescriptor(TestCase):
def setUp(self):
self.client = APIClient()
+ self.user_defined_data = {
+ 'key1': 'value1',
+ 'key2': 'value2',
+ 'key3': 'value3',
+ }
def tearDown(self):
pass
def test_pnfd_create_normal(self):
- reqest_data = {
- 'userDefinedData': {
- 'key1': 'value1',
- 'key2': 'value2',
- 'key3': 'value3',
- }
- }
+ request_data = {'userDefinedData': self.user_defined_data}
expected_reponse_data = {
'pnfdOnboardingState': 'CREATED',
'pnfdUsageState': 'NOT_IN_USE',
- 'userDefinedData': {
- 'key1': 'value1',
- 'key2': 'value2',
- 'key3': 'value3',
- },
+ 'userDefinedData': self.user_defined_data,
'_links': None
}
response = self.client.post(
'/api/nsd/v1/pnf_descriptors',
- data=reqest_data,
+ data=request_data,
format='json'
)
response.data.pop('id')
pass
def test_pnfd_content_upload_normal(self):
+ user_defined_data_json = json.JSONEncoder().encode(self.user_defined_data)
+ PnfPackageModel(
+ pnfPackageId='22',
+ usageState='NOT_IN_USE',
+ userDefinedData=user_defined_data_json,
+ ).save()
with open('pnfd_content.txt', 'wb') as fp:
fp.write('test')