def test_ns_manual_scale_asynchronous_tasks_success(
         self, mock_get, mock_sleep, mock_run, mock_vnf_data_info_list):
     mock_run.return_value = None
     mock_sleep.return_value = None
     mock_get.return_value = JobModel(progress=JOB_PROGRESS.FINISHED)
     mock_vnf_data_info_list.return_value = [{
         "vnfd_id": "nf_001",
         "vnf_scaleAspectId": "gpu",
         "numberOfSteps": "123"
     }, {
         "vnfd_id": "nf_002",
         "vnf_scaleAspectId": "gpu",
         "numberOfSteps": "456"
     }]
     scale_ns_json = SCALE_NS_THREAD_DICT.copy()
     ns_heal_service = NSManualScaleService(self.ns_inst_id, scale_ns_json,
                                            self.job_id)
     ns_heal_service.run()
     jobs = JobModel.objects.filter(jobid=self.job_id)
     self.assertEqual(
         NSInstModel.objects.get(id=self.ns_inst_id).status,
         NS_INST_STATUS.ACTIVE)
     self.assertEqual(JOB_PROGRESS.FINISHED, jobs[0].progress)
     self.assertEqual(
         NSLcmOpOccModel.objects.filter(
             id=ns_heal_service.occ_id).first().operation_state,
         'COMPLETED')
 def test_ns_manual_scale_asynchronous_tasks_when_error_scale_type(self):
     scale_ns_json = SCALE_NS_THREAD_DICT.copy()
     scale_ns_json['scaleType'] = 'SCALE_ERR'
     ns_heal_service = NSManualScaleService(self.ns_inst_id, scale_ns_json,
                                            self.job_id)
     ns_heal_service.run()
     jobs = JobModel.objects.filter(jobid=self.job_id)
     self.assertEqual(
         NSInstModel.objects.get(id=self.ns_inst_id).status,
         NS_INST_STATUS.ACTIVE)
     self.assertEqual(JOB_PROGRESS.ERROR, jobs[0].progress)
     self.assertEqual(
         NSLcmOpOccModel.objects.filter(
             id=ns_heal_service.occ_id).first().operation_state, 'FAILED')
 def test_ns_manual_scale_asynchronous_tasks_when_failed_to_get_scale_vnf_data_parameter(
         self, mock_vnf_data_info):
     mock_vnf_data_info.return_value = []
     scale_ns_json = SCALE_NS_THREAD_DICT.copy()
     ns_heal_service = NSManualScaleService(self.ns_inst_id, scale_ns_json,
                                            self.job_id)
     ns_heal_service.run()
     jobs = JobModel.objects.filter(jobid=self.job_id)
     self.assertEqual(
         NSInstModel.objects.get(id=self.ns_inst_id).status,
         NS_INST_STATUS.ACTIVE)
     self.assertEqual(JOB_PROGRESS.ERROR, jobs[0].progress)
     self.assertEqual(
         NSLcmOpOccModel.objects.filter(
             id=ns_heal_service.occ_id).first().operation_state, 'FAILED')
 def test_ns_manual_scale_asynchronous_tasks_when_scale_ns_by_steps_data_is_none(
         self):
     scale_ns_json = copy.deepcopy(SCALE_NS_THREAD_DICT)
     scale_ns_json['scaleNsData']["scaleNsByStepsData"] = None
     ns_heal_service = NSManualScaleService(self.ns_inst_id, scale_ns_json,
                                            self.job_id)
     ns_heal_service.run()
     jobs = JobModel.objects.filter(jobid=self.job_id)
     self.assertEqual(
         NSInstModel.objects.get(id=self.ns_inst_id).status,
         NS_INST_STATUS.ACTIVE)
     self.assertEqual(JOB_PROGRESS.ERROR, jobs[0].progress)
     self.assertEqual(
         NSLcmOpOccModel.objects.filter(
             id=ns_heal_service.occ_id).first().operation_state, 'FAILED')