aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-08-09 16:01:45 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-08-09 16:01:45 +0800
commit8506177af6d637ff21e72af3aa1b1ec2a4208323 (patch)
tree0b87a51658db45432dfd54d22662e44658061f31
parent205e810cea524b42a7842ae7e4474e8d45241fa8 (diff)
Add unit test for ns create
Change-Id: I3fee5c345be12b5866ad9fe39364d897925f494d Issue-ID: VFC-1009 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/ns/ns_create.py24
-rw-r--r--lcm/ns/tests/test_ns_create.py12
2 files changed, 12 insertions, 24 deletions
diff --git a/lcm/ns/ns_create.py b/lcm/ns/ns_create.py
index 40d8d501..1f99f22b 100644
--- a/lcm/ns/ns_create.py
+++ b/lcm/ns/ns_create.py
@@ -78,30 +78,6 @@ class CreateNSService(object):
def create_ns_in_aai(self):
logger.debug("CreateNSService::create_ns_in_aai::report ns instance[%s] to aai." % self.ns_inst_id)
try:
- # global_customer_id = "global-customer-id-" + self.ns_inst_id
- # data = {
- # "global-customer-id": "global-customer-id-" + self.ns_inst_id,
- # "subscriber-name": "subscriber-name-" + self.ns_inst_id,
- # "subscriber-type": "subscriber-type-" + self.ns_inst_id,
- # "service-subscriptions": {
- # "service-subscription": [
- # {
- # "service-type": "Network",
- # "service-instances": {
- # "service-instance": [
- # {
- # "service-instance-id": self.ns_inst_id,
- # "service-instance-name": self.ns_name,
- # "service-type": "Network",
- # "service-role": "service-role-" + self.ns_inst_id
- # }
- # ]
- # }
- # }
- # ]
- # }
- # }
- # resp_data, resp_status = create_customer_aai(global_customer_id, data)
data = {
"service-instance-id": self.ns_inst_id,
"service-instance-name": self.ns_name,
diff --git a/lcm/ns/tests/test_ns_create.py b/lcm/ns/tests/test_ns_create.py
index 61d87913..73ea2780 100644
--- a/lcm/ns/tests/test_ns_create.py
+++ b/lcm/ns/tests/test_ns_create.py
@@ -78,3 +78,15 @@ class TestNsInstantiate(TestCase):
self.assertEqual(response.data["error"], "nsd not exists.")
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
self.assertIn("error", response.data)
+
+ @mock.patch.object(restcall, 'call_req')
+ def test_create_ns_when_nsdid_not_exist(self, mock_call_req):
+ mock_call_req.return_value = [1, "Failed to get nsd.", '500']
+ data = {
+ 'csarId': '1',
+ 'nsName': 'ns',
+ 'description': 'description'
+ }
+ response = self.client.post("/api/nslcm/v1/ns", data=data)
+ self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
+ self.assertIn("error", response.data)